Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions cli/command/container/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -129,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:
Expand Down Expand Up @@ -209,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:
Expand Down Expand Up @@ -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)
}
}
Expand Down
19 changes: 2 additions & 17 deletions internal/jsonstream/display_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
}
}
Expand All @@ -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()
Expand Down
Loading