diff --git a/cmd/oras/internal/display/handler_test.go b/cmd/oras/internal/display/handler_test.go index 3303e59e9..f71981e5a 100644 --- a/cmd/oras/internal/display/handler_test.go +++ b/cmd/oras/internal/display/handler_test.go @@ -18,6 +18,7 @@ package display import ( "oras.land/oras/internal/testutils" "os" + "reflect" "testing" "oras.land/oras/cmd/oras/internal/display/metadata/text" @@ -28,7 +29,7 @@ import ( func TestNewPushHandler(t *testing.T) { mockFetcher := testutils.NewMockFetcher() - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) _, _, err := NewPushHandler(printer, option.Format{Type: option.FormatTypeText.Name}, os.Stdout, mockFetcher.Fetcher) if err != nil { t.Errorf("NewPushHandler() error = %v, want nil", err) @@ -37,7 +38,7 @@ func TestNewPushHandler(t *testing.T) { func TestNewAttachHandler(t *testing.T) { mockFetcher := testutils.NewMockFetcher() - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) _, _, err := NewAttachHandler(printer, option.Format{Type: option.FormatTypeText.Name}, os.Stdout, mockFetcher.Fetcher) if err != nil { t.Errorf("NewAttachHandler() error = %v, want nil", err) @@ -45,7 +46,7 @@ func TestNewAttachHandler(t *testing.T) { } func TestNewPullHandler(t *testing.T) { - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) _, _, err := NewPullHandler(printer, option.Format{Type: option.FormatTypeText.Name}, "", os.Stdout) if err != nil { t.Errorf("NewPullHandler() error = %v, want nil", err) @@ -53,7 +54,7 @@ func TestNewPullHandler(t *testing.T) { } func TestNewCopyHandler(t *testing.T) { - printer := output.NewPrinter(os.Stdout, os.Stderr, false) + printer := output.NewPrinter(os.Stdout, os.Stderr) copyHandler, copyMetadataHandler := NewCopyHandler(printer, os.Stdout, nil) if _, ok := copyHandler.(*status.TTYCopyHandler); !ok { t.Errorf("expected *status.TTYCopyHandler actual %v", reflect.TypeOf(copyHandler)) diff --git a/cmd/oras/internal/display/status/tty_console_test.go b/cmd/oras/internal/display/status/tty_console_test.go index f85237cce..b4d9aeb9b 100644 --- a/cmd/oras/internal/display/status/tty_console_test.go +++ b/cmd/oras/internal/display/status/tty_console_test.go @@ -18,10 +18,12 @@ limitations under the License. package status import ( + "strconv" + "testing" + "oras.land/oras-go/v2" "oras.land/oras-go/v2/content/memory" "oras.land/oras/internal/testutils" - "testing" ) type testGraphTarget struct { @@ -117,13 +119,13 @@ func TestTTYCopyHandler_OnCopySkipped(t *testing.T) { if err != nil { t.Fatal(err) } - defer ch.StopTracking() if err = ch.OnCopySkipped(ctx, mockFetcher.OciImage); err != nil { t.Errorf("OnCopySkipped() should not return an error: %v", err) } - if err = testutils.MatchPty(pty, slave, "\x1b[?25l\x1b7\x1b[0m"); err != nil { + ch.StopTracking() + if err = testutils.MatchPty(pty, slave, "Exists", mockFetcher.OciImage.MediaType, strconv.FormatInt(mockFetcher.OciImage.Size, 10), "100%"); err != nil { t.Fatal(err) } } diff --git a/cmd/oras/root/cp_test.go b/cmd/oras/root/cp_test.go index 05c6df801..3e01cff47 100644 --- a/cmd/oras/root/cp_test.go +++ b/cmd/oras/root/cp_test.go @@ -24,8 +24,6 @@ import ( "net/http" "net/http/httptest" "net/url" - "oras.land/oras/cmd/oras/internal/display/status" - "oras.land/oras/cmd/oras/internal/output" "os" "strings" "testing" @@ -131,11 +129,10 @@ func Test_doCopy(t *testing.T) { defer slave.Close() var opts copyOptions opts.TTY = slave - opts.Verbose = true opts.From.Reference = memDesc.Digest.String() dst := memory.New() builder := &strings.Builder{} - printer := output.NewPrinter(builder, os.Stderr, opts.Verbose) + printer := output.NewPrinter(builder, os.Stderr) handler := status.NewTextCopyHandler(printer, dst) // test _, err = doCopy(context.Background(), handler, memStore, dst, &opts) @@ -157,11 +154,10 @@ func Test_doCopy_skipped(t *testing.T) { defer slave.Close() var opts copyOptions opts.TTY = slave - opts.Verbose = true opts.From.Reference = memDesc.Digest.String() dst := memory.New() builder := &strings.Builder{} - printer := output.NewPrinter(builder, os.Stderr, opts.Verbose) + printer := output.NewPrinter(builder, os.Stderr) handler := status.NewTextCopyHandler(printer, dst) // test @@ -184,7 +180,6 @@ func Test_doCopy_mounted(t *testing.T) { defer slave.Close() var opts copyOptions opts.TTY = slave - opts.Verbose = true opts.From.Reference = manifestDigest // mocked repositories from, err := remote.NewRepository(fmt.Sprintf("%s/%s", host, repoFrom))