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..3b54d7121 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, "Skipped", mockFetcher.OciImage.MediaType, strconv.FormatInt(mockFetcher.OciImage.Size, 10), "100%"); err != nil { t.Fatal(err) } }