@@ -2,9 +2,7 @@ package container
22
33import (
44 "context"
5- "encoding/json"
65 "errors"
7- "fmt"
86 "io"
97 "net"
108 "syscall"
@@ -20,7 +18,8 @@ import (
2018 "github.com/docker/docker/api/types/container"
2119 "github.com/docker/docker/api/types/image"
2220 "github.com/docker/docker/api/types/network"
23- "github.com/docker/docker/pkg/jsonmessage"
21+ "github.com/docker/docker/pkg/progress"
22+ "github.com/docker/docker/pkg/streamformatter"
2423 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2524 "github.com/spf13/pflag"
2625 "gotest.tools/v3/assert"
@@ -242,23 +241,19 @@ func TestRunPullTermination(t *testing.T) {
242241 _ = server .Close ()
243242 })
244243 go func () {
245- enc := json .NewEncoder (server )
244+ id := test .RandomID ()[:12 ] // short-ID
245+ progressOutput := streamformatter .NewJSONProgressOutput (server , true )
246246 for i := 0 ; i < 100 ; i ++ {
247247 select {
248248 case <- ctx .Done ():
249249 assert .NilError (t , server .Close (), "failed to close imageCreateFunc server" )
250250 return
251251 default :
252- assert .NilError (t , enc .Encode (jsonmessage.JSONMessage {
253- Status : "Downloading" ,
254- ID : fmt .Sprintf ("id-%d" , i ),
255- TimeNano : time .Now ().UnixNano (),
256- Time : time .Now ().Unix (),
257- Progress : & jsonmessage.JSONProgress {
258- Current : int64 (i ),
259- Total : 100 ,
260- Start : 0 ,
261- },
252+ assert .NilError (t , progressOutput .WriteProgress (progress.Progress {
253+ ID : id ,
254+ Message : "Downloading" ,
255+ Current : int64 (i ),
256+ Total : 100 ,
262257 }))
263258 time .Sleep (100 * time .Millisecond )
264259 }
0 commit comments