From e47a5c7734547d0c63abea3a6071316e5f79c627 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 19 Feb 2026 09:28:24 +0100 Subject: [PATCH 1/2] remove redundant uses of streamformatter in tests The output of this was not used in the tests, and shouldn't be needed as part of it. Signed-off-by: Sebastiaan van Stijn --- cli/command/container/run_test.go | 12 +----------- internal/jsonstream/display_test.go | 19 ++----------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/cli/command/container/run_test.go b/cli/command/container/run_test.go index 8cc0b1bdc1a8..2daec2fe060d 100644 --- a/cli/command/container/run_test.go +++ b/cli/command/container/run_test.go @@ -16,8 +16,6 @@ import ( "github.com/moby/moby/api/types" "github.com/moby/moby/api/types/container" "github.com/moby/moby/client" - "github.com/moby/moby/client/pkg/progress" - "github.com/moby/moby/client/pkg/streamformatter" "github.com/spf13/pflag" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -245,20 +243,12 @@ func TestRunPullTermination(t *testing.T) { _ = server.Close() }) go func() { - id := test.RandomID()[:12] // short-ID - progressOutput := streamformatter.NewJSONProgressOutput(server, true) - for i := range 100 { + for range 100 { select { case <-ctx.Done(): assert.NilError(t, server.Close(), "failed to close imageCreateFunc server") return default: - assert.NilError(t, progressOutput.WriteProgress(progress.Progress{ - ID: id, - Message: "Downloading", - Current: int64(i), - Total: 100, - })) time.Sleep(100 * time.Millisecond) } } diff --git a/internal/jsonstream/display_test.go b/internal/jsonstream/display_test.go index b40679422a4d..813082e4f0b2 100644 --- a/internal/jsonstream/display_test.go +++ b/internal/jsonstream/display_test.go @@ -7,9 +7,6 @@ import ( "time" "github.com/docker/cli/cli/streams" - "github.com/docker/cli/internal/test" - "github.com/moby/moby/client/pkg/progress" - "github.com/moby/moby/client/pkg/streamformatter" "gotest.tools/v3/assert" ) @@ -23,23 +20,12 @@ func TestDisplay(t *testing.T) { }) go func() { - id := test.RandomID()[:12] // short-ID - progressOutput := streamformatter.NewJSONProgressOutput(server, true) - for i := range 100 { + for range 100 { select { case <-ctx.Done(): assert.NilError(t, server.Close(), "failed to close jsonmessage server") return default: - err := progressOutput.WriteProgress(progress.Progress{ - ID: id, - Message: "Downloading", - Current: int64(i), - Total: 100, - }) - if err != nil { - break - } time.Sleep(100 * time.Millisecond) } } @@ -50,8 +36,7 @@ func TestDisplay(t *testing.T) { done := make(chan error) go func() { - out := streams.NewOut(io.Discard) - done <- Display(streamCtx, client, out) + done <- Display(streamCtx, client, streams.NewOut(io.Discard)) }() cancelStream() From fdebf0afae0723d2a1556da48feba59b7db9a4d9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 19 Feb 2026 09:30:46 +0100 Subject: [PATCH 2/2] cli/command/container: fix some unhandled errors in test Signed-off-by: Sebastiaan van Stijn --- cli/command/container/run_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/container/run_test.go b/cli/command/container/run_test.go index 2daec2fe060d..00b0912abe34 100644 --- a/cli/command/container/run_test.go +++ b/cli/command/container/run_test.go @@ -127,7 +127,7 @@ func TestRunAttach(t *testing.T) { } // end stream from "container" so that we'll detach - conn.Close() + assert.NilError(t, conn.Close()) select { case cmdErr := <-cmdErrC: @@ -207,7 +207,7 @@ func TestRunAttachTermination(t *testing.T) { } assert.NilError(t, syscall.Kill(syscall.Getpid(), syscall.SIGTERM)) - conn.Close() + assert.NilError(t, conn.Close()) select { case <-killCh: