@@ -74,8 +74,8 @@ func TestNewLoadCommandInvalidInput(t *testing.T) {
7474 assert .ErrorContains (t , err , expectedError )
7575}
7676
77- func mockImageLoadResult (content string , json bool ) client.ImageLoadResult {
78- out := client.ImageLoadResult {JSON : json }
77+ func mockImageLoadResult (content string ) client.ImageLoadResult {
78+ out := client.ImageLoadResult {}
7979
8080 // Set unexported field "body"
8181 v := reflect .ValueOf (& out ).Elem ()
@@ -94,31 +94,21 @@ func TestNewLoadCommandSuccess(t *testing.T) {
9494 {
9595 name : "simple" ,
9696 args : []string {},
97- imageLoadFunc : func (input io.Reader , options ... client.ImageLoadOption ) (client.ImageLoadResult , error ) {
98- // FIXME(thaJeztah): how to mock this?
99- // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader("Success"))}, nil
100- return mockImageLoadResult (`Success` , false ), nil
101- },
102- },
103- {
104- name : "json" ,
105- args : []string {},
10697 imageLoadFunc : func (input io.Reader , options ... client.ImageLoadOption ) (client.ImageLoadResult , error ) {
10798 // FIXME(thaJeztah): how to mock this?
10899 // return client.ImageLoadResult{
109- // Body: io.NopCloser(strings.NewReader(`{"ID": "1"}`)),
110- // JSON: true,
100+ // Body: io.NopCloser(strings.NewReader(`{"ID":"simple","Status":"success"}`)),
111101 // }, nil
112- return mockImageLoadResult (`{"ID":"1"}` , true ), nil
102+ return mockImageLoadResult (`{"ID":"simple","Status":"success"}` ), nil
113103 },
114104 },
115105 {
116106 name : "input-file" ,
117107 args : []string {"--input" , "testdata/load-command-success.input.txt" },
118108 imageLoadFunc : func (input io.Reader , options ... client.ImageLoadOption ) (client.ImageLoadResult , error ) {
119109 // FIXME(thaJeztah): how to mock this?
120- // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader("Success" ))}, nil
121- return mockImageLoadResult (`Success` , false ), nil
110+ // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"input-file","Status":"success"}` ))}, nil
111+ return mockImageLoadResult (`{"ID":"input-file","Status":"success"}` ), nil
122112 },
123113 },
124114 {
@@ -129,8 +119,8 @@ func TestNewLoadCommandSuccess(t *testing.T) {
129119 assert .Check (t , len (options ) > 0 ) // can be 1 or two depending on whether a terminal is attached :/
130120 // assert.Check(t, is.Contains(options, client.ImageHistoryWithPlatform(ocispec.Platform{OS: "linux", Architecture: "amd64"})))
131121 // FIXME(thaJeztah): how to mock this?
132- // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader("Success" ))}, nil
133- return mockImageLoadResult (`Success` , false ), nil
122+ // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"single-platform","Status":"success"}` ))}, nil
123+ return mockImageLoadResult (`{"ID":"single-platform","Status":"success"}` ), nil
134124 },
135125 },
136126 {
@@ -139,8 +129,8 @@ func TestNewLoadCommandSuccess(t *testing.T) {
139129 imageLoadFunc : func (input io.Reader , options ... client.ImageLoadOption ) (client.ImageLoadResult , error ) {
140130 assert .Check (t , len (options ) > 0 ) // can be 1 or two depending on whether a terminal is attached :/
141131 // FIXME(thaJeztah): how to mock this?
142- // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader("Success" ))}, nil
143- return mockImageLoadResult (`Success` , false ), nil
132+ // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"with-comma-separated-platforms","Status":"success"}` ))}, nil
133+ return mockImageLoadResult (`{"ID":"with-comma-separated-platforms","Status":"success"}` ), nil
144134 },
145135 },
146136 {
@@ -149,8 +139,8 @@ func TestNewLoadCommandSuccess(t *testing.T) {
149139 imageLoadFunc : func (input io.Reader , options ... client.ImageLoadOption ) (client.ImageLoadResult , error ) {
150140 assert .Check (t , len (options ) > 0 ) // can be 1 or two depending on whether a terminal is attached :/
151141 // FIXME(thaJeztah): how to mock this?
152- // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader("Success" ))}, nil
153- return mockImageLoadResult (`Success` , false ), nil
142+ // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"with-multiple-platform-options","Status":"success"}` ))}, nil
143+ return mockImageLoadResult (`{"ID":"with-multiple-platform-options","Status":"success"}` ), nil
154144 },
155145 },
156146 }
0 commit comments