diff --git a/cmd/oras/internal/display/metadata/text/push_test.go b/cmd/oras/internal/display/metadata/text/push_test.go index 1ffbb9c37..c72a0a3e5 100644 --- a/cmd/oras/internal/display/metadata/text/push_test.go +++ b/cmd/oras/internal/display/metadata/text/push_test.go @@ -60,7 +60,7 @@ func TestPushHandler_OnCompleted(t *testing.T) { Digest: digest.FromBytes(content), Size: int64(len(content)), }, - false, // Printer ignores error + true, }, } for _, tt := range tests { diff --git a/cmd/oras/internal/output/print.go b/cmd/oras/internal/output/print.go index f257f3401..a3f6a42fc 100644 --- a/cmd/oras/internal/output/print.go +++ b/cmd/oras/internal/output/print.go @@ -58,8 +58,8 @@ func (p *Printer) Println(a ...any) error { if err != nil { err = fmt.Errorf("display output error: %w", err) _, _ = fmt.Fprint(p.err, err) + return err } - // Errors are handled above, so return nil return nil } diff --git a/cmd/oras/internal/output/print_test.go b/cmd/oras/internal/output/print_test.go index f63e9607d..9a1d8c586 100644 --- a/cmd/oras/internal/output/print_test.go +++ b/cmd/oras/internal/output/print_test.go @@ -48,8 +48,8 @@ func TestPrinter_Println(t *testing.T) { if mockWriter.errorCount != 1 { t.Error("Expected one error actual <" + strconv.Itoa(mockWriter.errorCount) + ">") } - if err != nil { - t.Error("Expected error to be ignored") + if err == nil { + t.Error("Expected error got ") } err = printer.Printf("boom") if mockWriter.errorCount != 2 {