github.com/alexandrev/docker@v1.9.0/integration-cli/docker_cli_search_test.go (about) 1 package main 2 3 import ( 4 "strings" 5 6 "github.com/docker/docker/pkg/integration/checker" 7 "github.com/go-check/check" 8 ) 9 10 // search for repos named "registry" on the central registry 11 func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) { 12 testRequires(c, Network, DaemonIsLinux) 13 14 out, _ := dockerCmd(c, "search", "busybox") 15 c.Assert(out, checker.Contains, "Busybox base image.", check.Commentf("couldn't find any repository named (or containing) 'Busybox base image.'")) 16 } 17 18 func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) { 19 out, _, err := dockerCmdWithError("search", "--stars=a", "busybox") 20 c.Assert(err, check.NotNil, check.Commentf(out)) 21 c.Assert(out, checker.Contains, "invalid value", check.Commentf("couldn't find the invalid value warning")) 22 23 out, _, err = dockerCmdWithError("search", "-s=-1", "busybox") 24 c.Assert(err, check.NotNil, check.Commentf(out)) 25 c.Assert(out, checker.Contains, "invalid value", check.Commentf("couldn't find the invalid value warning")) 26 } 27 28 func (s *DockerSuite) TestSearchCmdOptions(c *check.C) { 29 testRequires(c, Network) 30 31 out, _ := dockerCmd(c, "search", "--help") 32 c.Assert(out, checker.Contains, "Usage:\tdocker search [OPTIONS] TERM") 33 34 outSearchCmd, _ := dockerCmd(c, "search", "busybox") 35 outSearchCmdNotrunc, _ := dockerCmd(c, "search", "--no-trunc=true", "busybox") 36 c.Assert(len(outSearchCmd) > len(outSearchCmdNotrunc), check.Equals, false, check.Commentf("The no-trunc option can't take effect.")) 37 38 outSearchCmdautomated, _ := dockerCmd(c, "search", "--automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image. 39 outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n") 40 for i := range outSearchCmdautomatedSlice { 41 c.Assert(strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an AUTOMATED image: %s", out)) 42 } 43 44 outSearchCmdStars, _ := dockerCmd(c, "search", "-s=2", "busybox") 45 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)) 46 47 dockerCmd(c, "search", "--stars=2", "--automated=true", "--no-trunc=true", "busybox") 48 } 49 50 // search for repos which start with "ubuntu-" on the central registry 51 func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) { 52 testRequires(c, Network, DaemonIsLinux) 53 54 dockerCmd(c, "search", "ubuntu-") 55 }