1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/image/list_test.go
Cristina Yenyxe Gonzalez Garcia 0154dc7a23 Using test names instead of hardcoded ones in integration/image directory
Signed-off-by: Cristina Yenyxe Gonzalez Garcia <cristina.yenyxe@gmail.com>
2020-05-18 16:37:09 +01:00

53 lines
1.4 KiB
Go

package image // import "github.com/docker/docker/integration/image"
import (
"context"
"strings"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/versions"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/skip"
)
// Regression : #38171
func TestImagesFilterMultiReference(t *testing.T) {
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "broken in earlier versions")
defer setupTest(t)()
client := testEnv.APIClient()
ctx := context.Background()
name := strings.ToLower(t.Name())
repoTags := []string{
name + ":v1",
name + ":v2",
name + ":v3",
name + ":v4",
}
for _, repoTag := range repoTags {
err := client.ImageTag(ctx, "busybox:latest", repoTag)
assert.NilError(t, err)
}
filter := filters.NewArgs()
filter.Add("reference", repoTags[0])
filter.Add("reference", repoTags[1])
filter.Add("reference", repoTags[2])
options := types.ImageListOptions{
All: false,
Filters: filter,
}
images, err := client.ImageList(ctx, options)
assert.NilError(t, err)
assert.Check(t, is.Equal(len(images[0].RepoTags), 3))
for _, repoTag := range images[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)
}
}
}