Skip to content

Commit

Permalink
fix: broken tty tests
Browse files Browse the repository at this point in the history
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
  • Loading branch information
TerryHowe committed Dec 4, 2024
1 parent 31eaf93 commit 1f71707
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions cmd/oras/root/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import (
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"

"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras-go/v2/content/memory"
"oras.land/oras-go/v2/registry/remote"
"oras.land/oras/cmd/oras/internal/display/status"
"oras.land/oras/cmd/oras/internal/output"
"oras.land/oras/internal/testutils"
)

Expand Down Expand Up @@ -131,9 +129,7 @@ func Test_doCopy(t *testing.T) {
opts.TTY = slave
opts.From.Reference = memDesc.Digest.String()
dst := memory.New()
builder := &strings.Builder{}
printer := output.NewPrinter(builder, os.Stderr)
handler := status.NewTextCopyHandler(printer, dst)
handler := status.NewTTYCopyHandler(opts.TTY)
// test
_, err = doCopy(context.Background(), handler, memStore, dst, &opts)
if err != nil {
Expand All @@ -155,17 +151,15 @@ func Test_doCopy_skipped(t *testing.T) {
var opts copyOptions
opts.TTY = slave
opts.From.Reference = memDesc.Digest.String()
builder := &strings.Builder{}
printer := output.NewPrinter(builder, os.Stderr)
handler := status.NewTextCopyHandler(printer, memStore)
handler := status.NewTTYCopyHandler(opts.TTY)

// test
_, err = doCopy(context.Background(), handler, memStore, memStore, &opts)
if err != nil {
t.Fatal(err)
}
// validate
if err = testutils.MatchPty(pty, slave, "Exists", memDesc.MediaType, "100.00%", memDesc.Digest.String()); err != nil {
if err = testutils.MatchPty(pty, slave, "Exists", "oci-image", "100.00%", memDesc.Digest.String()); err != nil {
t.Fatal(err)
}
}
Expand All @@ -191,10 +185,7 @@ func Test_doCopy_mounted(t *testing.T) {
t.Fatal(err)
}
to.PlainHTTP = true
builder := &strings.Builder{}
printer := output.NewPrinter(builder, os.Stderr)
printer.Verbose = true
handler := status.NewTextCopyHandler(printer, to)
handler := status.NewTTYCopyHandler(opts.TTY)

// test
_, err = doCopy(context.Background(), handler, from, to, &opts)
Expand Down

0 comments on commit 1f71707

Please sign in to comment.