summaryrefslogtreecommitdiff
path: root/integration-cli/docker_cli_search_test.go
diff options
context:
space:
mode:
authorFabrizio Soppelsa <fsoppelsa@mirantis.com>2016-05-20 13:41:28 +0200
committerVincent Demeester <vincent@sbr.pm>2016-05-20 13:41:28 +0200
commite009ebdf4c0bf0ff64da8d48eefad63d0644de3e (patch)
tree5d0f31187327eb5b3b0ee3ef449e488a80387e08 /integration-cli/docker_cli_search_test.go
parent0e9009bae3a493cfce8a8334949b239efcb88f43 (diff)
downloaddocker-e009ebdf4c0bf0ff64da8d48eefad63d0644de3e.tar.gz
Add a --filter option to `docker search`
The filtering is made server-side, and the following filters are supported: * is-official (boolean) * is-automated (boolean) * has-stars (integer) Signed-off-by: Fabrizio Soppelsa <fsoppelsa@mirantis.com> Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat (limited to 'integration-cli/docker_cli_search_test.go')
-rw-r--r--integration-cli/docker_cli_search_test.go54
1 files changed, 49 insertions, 5 deletions
diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go
index dfab81044a..a93d657265 100644
--- a/integration-cli/docker_cli_search_test.go
+++ b/integration-cli/docker_cli_search_test.go
@@ -16,34 +16,78 @@ func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) {
}
func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) {
- out, _, err := dockerCmdWithError("search", "--stars=a", "busybox")
+ out, _, err := dockerCmdWithError("search", "--filter", "stars=a", "busybox")
+ c.Assert(err, check.NotNil, check.Commentf(out))
+ c.Assert(out, checker.Contains, "Invalid filter", check.Commentf("couldn't find the invalid filter warning"))
+
+ out, _, err = dockerCmdWithError("search", "-f", "stars=a", "busybox")
+ c.Assert(err, check.NotNil, check.Commentf(out))
+ c.Assert(out, checker.Contains, "Invalid filter", check.Commentf("couldn't find the invalid filter warning"))
+
+ out, _, err = dockerCmdWithError("search", "-f", "is-automated=a", "busybox")
+ c.Assert(err, check.NotNil, check.Commentf(out))
+ c.Assert(out, checker.Contains, "Invalid filter", check.Commentf("couldn't find the invalid filter warning"))
+
+ out, _, err = dockerCmdWithError("search", "-f", "is-official=a", "busybox")
+ c.Assert(err, check.NotNil, check.Commentf(out))
+ c.Assert(out, checker.Contains, "Invalid filter", check.Commentf("couldn't find the invalid filter warning"))
+
+ // -s --stars deprecated since Docker 1.13
+ out, _, err = dockerCmdWithError("search", "--stars=a", "busybox")
c.Assert(err, check.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "invalid value", check.Commentf("couldn't find the invalid value warning"))
+ // -s --stars deprecated since Docker 1.13
out, _, err = dockerCmdWithError("search", "-s=-1", "busybox")
c.Assert(err, check.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "invalid value", check.Commentf("couldn't find the invalid value warning"))
}
func (s *DockerSuite) TestSearchCmdOptions(c *check.C) {
- testRequires(c, Network)
+ testRequires(c, Network, DaemonIsLinux)
out, _ := dockerCmd(c, "search", "--help")
c.Assert(out, checker.Contains, "Usage:\tdocker search [OPTIONS] TERM")
outSearchCmd, _ := dockerCmd(c, "search", "busybox")
outSearchCmdNotrunc, _ := dockerCmd(c, "search", "--no-trunc=true", "busybox")
+
c.Assert(len(outSearchCmd) > len(outSearchCmdNotrunc), check.Equals, false, check.Commentf("The no-trunc option can't take effect."))
- outSearchCmdautomated, _ := dockerCmd(c, "search", "--automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image.
+ outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image.
outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n")
for i := range outSearchCmdautomatedSlice {
- c.Assert(strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an AUTOMATED image: %s", out))
+ c.Assert(strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an AUTOMATED image: %s", outSearchCmdautomated))
+ }
+
+ outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") //The busybox is a busybox base image, official image.
+ outSearchCmdNotOfficialSlice := strings.Split(outSearchCmdNotOfficial, "\n")
+ for i := range outSearchCmdNotOfficialSlice {
+ c.Assert(strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial))
}
- outSearchCmdStars, _ := dockerCmd(c, "search", "-s=2", "busybox")
+ outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") //The busybox is a busybox base image, official image.
+ outSearchCmdOfficialSlice := strings.Split(outSearchCmdOfficial, "\n")
+ c.Assert(outSearchCmdOfficialSlice, checker.HasLen, 3) // 1 header, 1 line, 1 carriage return
+ c.Assert(strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), check.Equals, true, check.Commentf("The busybox is an OFFICIAL image: %s", outSearchCmdNotOfficial))
+
+ outSearchCmdStars, _ := dockerCmd(c, "search", "--filter", "stars=2", "busybox")
c.Assert(strings.Count(outSearchCmdStars, "[OK]") > strings.Count(outSearchCmd, "[OK]"), check.Equals, false, check.Commentf("The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars))
+ dockerCmd(c, "search", "--filter", "is-automated=true", "--filter", "stars=2", "--no-trunc=true", "busybox")
+
+ // --automated deprecated since Docker 1.13
+ outSearchCmdautomated1, _ := dockerCmd(c, "search", "--automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image.
+ outSearchCmdautomatedSlice1 := strings.Split(outSearchCmdautomated1, "\n")
+ for i := range outSearchCmdautomatedSlice1 {
+ c.Assert(strings.HasPrefix(outSearchCmdautomatedSlice1[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an AUTOMATED image: %s", outSearchCmdautomated))
+ }
+
+ // -s --stars deprecated since Docker 1.13
+ outSearchCmdStars1, _ := dockerCmd(c, "search", "--stars=2", "busybox")
+ c.Assert(strings.Count(outSearchCmdStars1, "[OK]") > strings.Count(outSearchCmd, "[OK]"), check.Equals, false, check.Commentf("The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars1))
+
+ // -s --stars deprecated since Docker 1.13
dockerCmd(c, "search", "--stars=2", "--automated=true", "--no-trunc=true", "busybox")
}