mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: simplify test with mock-responses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@@ -79,22 +76,10 @@ func TestImageRemove(t *testing.T) {
|
||||
return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual)
|
||||
}
|
||||
}
|
||||
b, err := json.Marshal([]image.DeleteResponse{
|
||||
{
|
||||
Untagged: "image_id1",
|
||||
},
|
||||
{
|
||||
Deleted: "image_id",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: io.NopCloser(bytes.NewReader(b)),
|
||||
}, nil
|
||||
return mockJSONResponse(http.StatusOK, nil, []image.DeleteResponse{
|
||||
{Untagged: "image_id1"},
|
||||
{Deleted: "image_id"},
|
||||
})(req)
|
||||
}))
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user