From 341ceb8189550bdcea55dc8113af36d7529eb0cb Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Mon, 22 Jul 2024 19:07:33 -0600 Subject: [PATCH] chore: Bring back the print error (#1451) Signed-off-by: Terry Howe --- cmd/oras/internal/display/metadata/text/push_test.go | 2 +- cmd/oras/internal/output/print.go | 2 +- cmd/oras/internal/output/print_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) 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 {