File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed
Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ package jsonstream
22
33import (
44 "context"
5- "encoding/json"
6- "fmt"
75 "io"
86 "testing"
97 "time"
108
119 "github.com/docker/cli/cli/streams"
12- "github.com/moby/moby/api/types/jsonstream"
10+ "github.com/docker/cli/internal/test"
11+ "github.com/moby/moby/client/pkg/progress"
12+ "github.com/moby/moby/client/pkg/streamformatter"
1313 "gotest.tools/v3/assert"
1414)
1515
@@ -23,21 +23,19 @@ func TestDisplay(t *testing.T) {
2323 })
2424
2525 go func () {
26- enc := json .NewEncoder (server )
26+ id := test .RandomID ()[:12 ] // short-ID
27+ progressOutput := streamformatter .NewJSONProgressOutput (server , true )
2728 for i := 0 ; i < 100 ; i ++ {
2829 select {
2930 case <- ctx .Done ():
3031 assert .NilError (t , server .Close (), "failed to close jsonmessage server" )
3132 return
3233 default :
33- err := enc .Encode (JSONMessage {
34- Status : "Downloading" ,
35- ID : fmt .Sprintf ("id-%d" , i ),
36- Progress : & jsonstream.Progress {
37- Current : int64 (i ),
38- Total : 100 ,
39- Start : 0 ,
40- },
34+ err := progressOutput .WriteProgress (progress.Progress {
35+ ID : id ,
36+ Message : "Downloading" ,
37+ Current : int64 (i ),
38+ Total : 100 ,
4139 })
4240 if err != nil {
4341 break
You can’t perform that action at this time.
0 commit comments