This reverts commit 21e662c77468d1e3fc4efaa049021e2ad0e49b4d.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -44,6 +44,54 @@ func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) {
|
| 44 | 44 |
assert.Assert(c, strings.Contains(out, "invalid syntax"), "couldn't find the invalid value warning") |
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 |
+func (s *DockerSuite) TestSearchCmdOptions(c *check.C) {
|
|
| 48 |
+ testRequires(c, Network, DaemonIsLinux) |
|
| 49 |
+ |
|
| 50 |
+ out, _ := dockerCmd(c, "search", "--help") |
|
| 51 |
+ assert.Assert(c, strings.Contains(out, "Usage:\tdocker search [OPTIONS] TERM")) |
|
| 52 |
+ |
|
| 53 |
+ outSearchCmd, _ := dockerCmd(c, "search", "busybox") |
|
| 54 |
+ assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd) |
|
| 55 |
+ outSearchCmdNotrunc, _ := dockerCmd(c, "search", "--no-trunc=true", "busybox") |
|
| 56 |
+ assert.Assert(c, len(outSearchCmd) <= len(outSearchCmdNotrunc), "The no-trunc option can't take effect.") |
|
| 57 |
+ |
|
| 58 |
+ outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image. |
|
| 59 |
+ outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n") |
|
| 60 |
+ for i := range outSearchCmdautomatedSlice {
|
|
| 61 |
+ assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated) |
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") //The busybox is a busybox base image, official image. |
|
| 65 |
+ outSearchCmdNotOfficialSlice := strings.Split(outSearchCmdNotOfficial, "\n") |
|
| 66 |
+ for i := range outSearchCmdNotOfficialSlice {
|
|
| 67 |
+ assert.Assert(c, !strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), "The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial) |
|
| 68 |
+ } |
|
| 69 |
+ |
|
| 70 |
+ outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") //The busybox is a busybox base image, official image. |
|
| 71 |
+ outSearchCmdOfficialSlice := strings.Split(outSearchCmdOfficial, "\n") |
|
| 72 |
+ assert.Equal(c, len(outSearchCmdOfficialSlice), 3) // 1 header, 1 line, 1 carriage return |
|
| 73 |
+ assert.Assert(c, strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), "The busybox is an OFFICIAL image: %s", outSearchCmdOfficial) |
|
| 74 |
+ |
|
| 75 |
+ outSearchCmdStars, _ := dockerCmd(c, "search", "--filter", "stars=10", "busybox") |
|
| 76 |
+ assert.Assert(c, strings.Count(outSearchCmdStars, "\n") <= strings.Count(outSearchCmd, "\n"), "Number of images with 10+ stars should be less than that of all images:\noutSearchCmdStars: %s\noutSearch: %s\n", outSearchCmdStars, outSearchCmd) |
|
| 77 |
+ |
|
| 78 |
+ dockerCmd(c, "search", "--filter", "is-automated=true", "--filter", "stars=2", "--no-trunc=true", "busybox") |
|
| 79 |
+ |
|
| 80 |
+ // --automated deprecated since Docker 1.13 |
|
| 81 |
+ outSearchCmdautomated1, _ := dockerCmd(c, "search", "--automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image. |
|
| 82 |
+ outSearchCmdautomatedSlice1 := strings.Split(outSearchCmdautomated1, "\n") |
|
| 83 |
+ for i := range outSearchCmdautomatedSlice1 {
|
|
| 84 |
+ assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice1[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated) |
|
| 85 |
+ } |
|
| 86 |
+ |
|
| 87 |
+ // -s --stars deprecated since Docker 1.13 |
|
| 88 |
+ outSearchCmdStars1, _ := dockerCmd(c, "search", "--stars=2", "busybox") |
|
| 89 |
+ assert.Assert(c, strings.Count(outSearchCmdStars1, "[OK]") <= strings.Count(outSearchCmd, "[OK]"), "The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars1) |
|
| 90 |
+ |
|
| 91 |
+ // -s --stars deprecated since Docker 1.13 |
|
| 92 |
+ dockerCmd(c, "search", "--stars=2", "--automated=true", "--no-trunc=true", "busybox") |
|
| 93 |
+} |
|
| 94 |
+ |
|
| 47 | 95 |
// search for repos which start with "ubuntu-" on the central registry |
| 48 | 96 |
func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) {
|
| 49 | 97 |
testRequires(c, Network, DaemonIsLinux) |