mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client/image_list: Wrap options and result
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
committed by
Austin Vazquez
parent
a7f409014f
commit
b3974f07f5
@@ -47,7 +47,7 @@ func TestExportContainerAndImportImage(t *testing.T) {
|
||||
Filters: make(client.Filters).Add("reference", reference),
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(jm.Status, images.Images[0].ID))
|
||||
assert.Check(t, is.Equal(jm.Status, images.Items[0].ID))
|
||||
}
|
||||
|
||||
// TestExportContainerAfterDaemonRestart checks that a container
|
||||
|
||||
@@ -136,7 +136,7 @@ func TestMigrateSaveLoad(t *testing.T) {
|
||||
// Delete all images
|
||||
list, err := apiClient.ImageList(ctx, client.ImageListOptions{})
|
||||
assert.NilError(t, err)
|
||||
for _, i := range list {
|
||||
for _, i := range list.Items {
|
||||
_, err = apiClient.ImageRemove(ctx, i.ID, client.ImageRemoveOptions{Force: true})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ func TestImagesFilterMultiReference(t *testing.T) {
|
||||
options := client.ImageListOptions{
|
||||
Filters: make(client.Filters).Add("reference", repoTags[:3]...),
|
||||
}
|
||||
images, err := apiClient.ImageList(ctx, options)
|
||||
imageList, err := apiClient.ImageList(ctx, options)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Assert(t, is.Len(images, 1))
|
||||
assert.Check(t, is.Len(images[0].RepoTags, 3))
|
||||
for _, repoTag := range images[0].RepoTags {
|
||||
assert.Assert(t, is.Len(imageList.Items, 1))
|
||||
assert.Check(t, is.Len(imageList.Items[0].RepoTags, 3))
|
||||
for _, repoTag := range imageList.Items[0].RepoTags {
|
||||
if repoTag != repoTags[0] && repoTag != repoTags[1] && repoTag != repoTags[2] {
|
||||
t.Errorf("list images doesn't match any repoTag we expected, repoTag: %s", repoTag)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func TestImagesFilterUntil(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
|
||||
var listedIDs []string
|
||||
for _, i := range list {
|
||||
for _, i := range list.Items {
|
||||
t.Logf("ImageList: ID=%v RepoTags=%v", i.ID, i.RepoTags)
|
||||
listedIDs = append(listedIDs, i.ID)
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func TestImagesFilterBeforeSince(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
|
||||
var listedIDs []string
|
||||
for _, i := range list {
|
||||
for _, i := range list.Items {
|
||||
t.Logf("ImageList: ID=%v RepoTags=%v", i.ID, i.RepoTags)
|
||||
listedIDs = append(listedIDs, i.ID)
|
||||
}
|
||||
@@ -181,12 +181,12 @@ func TestAPIImagesFilters(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := testutil.StartSpan(ctx, t)
|
||||
images, err := apiClient.ImageList(ctx, client.ImageListOptions{
|
||||
imageList, err := apiClient.ImageList(ctx, client.ImageListOptions{
|
||||
Filters: tc.filters,
|
||||
})
|
||||
assert.Check(t, err)
|
||||
assert.Assert(t, is.Len(images, tc.expectedImages))
|
||||
assert.Check(t, is.Len(images[0].RepoTags, tc.expectedRepoTags))
|
||||
assert.Assert(t, is.Len(imageList.Items, tc.expectedImages))
|
||||
assert.Check(t, is.Len(imageList.Items[0].RepoTags, tc.expectedRepoTags))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -255,31 +255,31 @@ func TestAPIImagesListManifests(t *testing.T) {
|
||||
// TODO: Remove when MinAPIVersion >= 1.47
|
||||
c := d.NewClientT(t, client.WithVersion("1.46"))
|
||||
|
||||
images, err := c.ImageList(ctx, client.ImageListOptions{Manifests: true})
|
||||
imageList, err := c.ImageList(ctx, client.ImageListOptions{Manifests: true})
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Assert(t, is.Len(images, 1))
|
||||
assert.Check(t, is.Nil(images[0].Manifests))
|
||||
assert.Assert(t, is.Len(imageList.Items, 1))
|
||||
assert.Check(t, is.Nil(imageList.Items[0].Manifests))
|
||||
})
|
||||
|
||||
api147 := d.NewClientT(t, client.WithVersion("1.47"))
|
||||
|
||||
t.Run("no manifests if not requested", func(t *testing.T) {
|
||||
images, err := api147.ImageList(ctx, client.ImageListOptions{})
|
||||
imageList, err := api147.ImageList(ctx, client.ImageListOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Assert(t, is.Len(images, 1))
|
||||
assert.Check(t, is.Nil(images[0].Manifests))
|
||||
assert.Assert(t, is.Len(imageList.Items, 1))
|
||||
assert.Check(t, is.Nil(imageList.Items[0].Manifests))
|
||||
})
|
||||
|
||||
images, err := api147.ImageList(ctx, client.ImageListOptions{Manifests: true})
|
||||
imageList, err := api147.ImageList(ctx, client.ImageListOptions{Manifests: true})
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Check(t, is.Len(images, 1))
|
||||
assert.Check(t, images[0].Manifests != nil)
|
||||
assert.Check(t, is.Len(images[0].Manifests, 3))
|
||||
assert.Check(t, is.Len(imageList.Items, 1))
|
||||
assert.Check(t, imageList.Items[0].Manifests != nil)
|
||||
assert.Check(t, is.Len(imageList.Items[0].Manifests, 3))
|
||||
|
||||
for _, mfst := range images[0].Manifests {
|
||||
for _, mfst := range imageList.Items[0].Manifests {
|
||||
// All manifests should be image manifests
|
||||
assert.Check(t, is.Equal(mfst.Kind, image.ManifestKindImage))
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestLoadDanglingImages(t *testing.T) {
|
||||
})
|
||||
|
||||
// Should be one image.
|
||||
images, err := apiClient.ImageList(ctx, client.ImageListOptions{})
|
||||
imageList, err := apiClient.ImageList(ctx, client.ImageListOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
findImageByName := func(images []image.Summary, imageName string) (image.Summary, error) {
|
||||
@@ -42,7 +42,7 @@ func TestLoadDanglingImages(t *testing.T) {
|
||||
return images[index], nil
|
||||
}
|
||||
|
||||
oldImage, err := findImageByName(images, "namedimage:latest")
|
||||
oldImage, err := findImageByName(imageList.Items, "namedimage:latest")
|
||||
assert.NilError(t, err)
|
||||
|
||||
// Retain a copy of the old image and then replace it with a new one.
|
||||
@@ -52,10 +52,10 @@ func TestLoadDanglingImages(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
images, err = apiClient.ImageList(ctx, client.ImageListOptions{})
|
||||
imageList, err = apiClient.ImageList(ctx, client.ImageListOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
newImage, err := findImageByName(images, "namedimage:latest")
|
||||
newImage, err := findImageByName(imageList.Items, "namedimage:latest")
|
||||
assert.NilError(t, err)
|
||||
|
||||
// IDs should be different.
|
||||
@@ -72,7 +72,7 @@ func TestLoadDanglingImages(t *testing.T) {
|
||||
return images[index], nil
|
||||
}
|
||||
|
||||
danglingImage, err := findImageById(images, oldImage.ID)
|
||||
danglingImage, err := findImageById(imageList.Items, oldImage.ID)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(danglingImage.RepoTags, 0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user