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 c045669
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/oras/internal/display/status/tty_console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestTTYCopyHandler_OnCopySkipped(t *testing.T) {
}

ch.StopTracking()

Check failure on line 130 in cmd/oras/internal/display/status/tty_console_test.go

View workflow job for this annotation

GitHub Actions / lint (1.23)

Error return value of `ch.StopTracking` is not checked (errcheck)
if err = testutils.MatchPty(pty, slave, "Exists", mockFetcher.OciImage.MediaType, strconv.FormatInt(mockFetcher.OciImage.Size, 10), "100%"); err != nil {
if err = testutils.MatchPty(pty, slave, "Exists", "oci-image", strconv.FormatInt(mockFetcher.OciImage.Size, 10), "100.00%"); err != nil {
t.Fatal(err)
}
}
Expand Down
15 changes: 3 additions & 12 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,9 +151,7 @@ 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)
Expand Down Expand Up @@ -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 c045669

Please sign in to comment.