client: Change ImageLoad to use functional options

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-02-14 13:54:11 +01:00
parent 85808a6abf
commit ae4c688fd8
8 changed files with 59 additions and 19 deletions

View File

@@ -8,7 +8,6 @@ import (
"net/url"
"testing"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/errdefs"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert"
@@ -20,7 +19,7 @@ func TestImageLoadError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
}
_, err := client.ImageLoad(context.Background(), nil, image.LoadOptions{Quiet: true})
_, err := client.ImageLoad(context.Background(), nil, ImageLoadWithQuiet(true))
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
}
@@ -97,10 +96,10 @@ func TestImageLoad(t *testing.T) {
}
input := bytes.NewReader([]byte(expectedInput))
imageLoadResponse, err := client.ImageLoad(context.Background(), input, image.LoadOptions{
Quiet: tc.quiet,
Platforms: tc.platforms,
})
imageLoadResponse, err := client.ImageLoad(context.Background(), input,
ImageLoadWithQuiet(tc.quiet),
ImageLoadWithPlatforms(tc.platforms...),
)
assert.NilError(t, err)
assert.Check(t, is.Equal(imageLoadResponse.JSON, tc.expectedResponseJSON))