Skip to content

Commit 44ca067

Browse files
authored
Merge pull request #6807 from thaJeztah/less_streamformatter
remove redundant uses of streamformatter in tests
2 parents 63158f7 + fdebf0a commit 44ca067

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

cli/command/container/run_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import (
1616
"github.com/moby/moby/api/types"
1717
"github.com/moby/moby/api/types/container"
1818
"github.com/moby/moby/client"
19-
"github.com/moby/moby/client/pkg/progress"
20-
"github.com/moby/moby/client/pkg/streamformatter"
2119
"github.com/spf13/pflag"
2220
"gotest.tools/v3/assert"
2321
is "gotest.tools/v3/assert/cmp"
@@ -129,7 +127,7 @@ func TestRunAttach(t *testing.T) {
129127
}
130128

131129
// end stream from "container" so that we'll detach
132-
conn.Close()
130+
assert.NilError(t, conn.Close())
133131

134132
select {
135133
case cmdErr := <-cmdErrC:
@@ -209,7 +207,7 @@ func TestRunAttachTermination(t *testing.T) {
209207
}
210208

211209
assert.NilError(t, syscall.Kill(syscall.Getpid(), syscall.SIGTERM))
212-
conn.Close()
210+
assert.NilError(t, conn.Close())
213211

214212
select {
215213
case <-killCh:
@@ -245,20 +243,12 @@ func TestRunPullTermination(t *testing.T) {
245243
_ = server.Close()
246244
})
247245
go func() {
248-
id := test.RandomID()[:12] // short-ID
249-
progressOutput := streamformatter.NewJSONProgressOutput(server, true)
250-
for i := range 100 {
246+
for range 100 {
251247
select {
252248
case <-ctx.Done():
253249
assert.NilError(t, server.Close(), "failed to close imageCreateFunc server")
254250
return
255251
default:
256-
assert.NilError(t, progressOutput.WriteProgress(progress.Progress{
257-
ID: id,
258-
Message: "Downloading",
259-
Current: int64(i),
260-
Total: 100,
261-
}))
262252
time.Sleep(100 * time.Millisecond)
263253
}
264254
}

internal/jsonstream/display_test.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import (
77
"time"
88

99
"github.com/docker/cli/cli/streams"
10-
"github.com/docker/cli/internal/test"
11-
"github.com/moby/moby/client/pkg/progress"
12-
"github.com/moby/moby/client/pkg/streamformatter"
1310
"gotest.tools/v3/assert"
1411
)
1512

@@ -23,23 +20,12 @@ func TestDisplay(t *testing.T) {
2320
})
2421

2522
go func() {
26-
id := test.RandomID()[:12] // short-ID
27-
progressOutput := streamformatter.NewJSONProgressOutput(server, true)
28-
for i := range 100 {
23+
for range 100 {
2924
select {
3025
case <-ctx.Done():
3126
assert.NilError(t, server.Close(), "failed to close jsonmessage server")
3227
return
3328
default:
34-
err := progressOutput.WriteProgress(progress.Progress{
35-
ID: id,
36-
Message: "Downloading",
37-
Current: int64(i),
38-
Total: 100,
39-
})
40-
if err != nil {
41-
break
42-
}
4329
time.Sleep(100 * time.Millisecond)
4430
}
4531
}
@@ -50,8 +36,7 @@ func TestDisplay(t *testing.T) {
5036

5137
done := make(chan error)
5238
go func() {
53-
out := streams.NewOut(io.Discard)
54-
done <- Display(streamCtx, client, out)
39+
done <- Display(streamCtx, client, streams.NewOut(io.Discard))
5540
}()
5641

5742
cancelStream()

0 commit comments

Comments
 (0)