2018-11-09 22:00:26 -05:00
|
|
|
package image // import "github.com/docker/docker/integration/image"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-18 11:26:44 -04:00
|
|
|
"strings"
|
2018-11-09 22:00:26 -05:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
2019-04-19 14:38:28 -04:00
|
|
|
"github.com/docker/docker/api/types/versions"
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
|
|
|
"gotest.tools/v3/skip"
|
2018-11-09 22:00:26 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Regression : #38171
|
|
|
|
func TestImagesFilterMultiReference(t *testing.T) {
|
2019-04-19 14:38:28 -04:00
|
|
|
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "broken in earlier versions")
|
2018-11-09 22:00:26 -05:00
|
|
|
defer setupTest(t)()
|
2019-01-02 08:16:25 -05:00
|
|
|
client := testEnv.APIClient()
|
2018-11-09 22:00:26 -05:00
|
|
|
ctx := context.Background()
|
|
|
|
|
2020-05-18 11:26:44 -04:00
|
|
|
name := strings.ToLower(t.Name())
|
2018-11-09 22:00:26 -05:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|