mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #39258 from thaJeztah/revert_remove_TestSearchCmdOptions
Revert "Remove TestSearchCmdOptions test"
This commit is contained in:
commit
b4058a6c91
1 changed files with 35 additions and 38 deletions
|
@ -10,8 +10,6 @@ import (
|
|||
|
||||
// search for repos named "registry" on the central registry
|
||||
func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) {
|
||||
testRequires(c, Network, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmd(c, "search", "busybox")
|
||||
assert.Assert(c, strings.Contains(out, "Busybox base image."), "couldn't find any repository named (or containing) 'Busybox base image.'")
|
||||
}
|
||||
|
@ -32,52 +30,51 @@ func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) {
|
|||
out, _, err = dockerCmdWithError("search", "-f", "is-official=a", "busybox")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
|
||||
}
|
||||
|
||||
// -s --stars deprecated since Docker 1.13
|
||||
out, _, err = dockerCmdWithError("search", "--stars=a", "busybox")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, strings.Contains(out, "invalid syntax"), "couldn't find the invalid value warning")
|
||||
func (s *DockerSuite) TestSearchCmdOptions(c *check.C) {
|
||||
outSearchCmd, _ := dockerCmd(c, "search", "busybox")
|
||||
assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd)
|
||||
|
||||
// -s --stars deprecated since Docker 1.13
|
||||
out, _, err = dockerCmdWithError("search", "-s=-1", "busybox")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, strings.Contains(out, "invalid syntax"), "couldn't find the invalid value warning")
|
||||
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 {
|
||||
assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), "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 {
|
||||
assert.Assert(c, !strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), "The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial)
|
||||
}
|
||||
|
||||
outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") //The busybox is a busybox base image, official image.
|
||||
outSearchCmdOfficialSlice := strings.Split(outSearchCmdOfficial, "\n")
|
||||
assert.Equal(c, len(outSearchCmdOfficialSlice), 3) // 1 header, 1 line, 1 carriage return
|
||||
assert.Assert(c, strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), "The busybox is an OFFICIAL image: %s", outSearchCmdOfficial)
|
||||
|
||||
outSearchCmdStars, _ := dockerCmd(c, "search", "--filter", "stars=10", "busybox")
|
||||
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)
|
||||
|
||||
dockerCmd(c, "search", "--filter", "is-automated=true", "--filter", "stars=2", "--no-trunc=true", "busybox")
|
||||
}
|
||||
|
||||
// search for repos which start with "ubuntu-" on the central registry
|
||||
func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) {
|
||||
testRequires(c, Network, DaemonIsLinux)
|
||||
|
||||
dockerCmd(c, "search", "ubuntu-")
|
||||
}
|
||||
|
||||
// test case for #23055
|
||||
func (s *DockerSuite) TestSearchWithLimit(c *check.C) {
|
||||
testRequires(c, Network, DaemonIsLinux)
|
||||
for _, limit := range []int{10, 50, 100} {
|
||||
out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.NilError(c, err)
|
||||
outSlice := strings.Split(out, "\n")
|
||||
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
||||
}
|
||||
|
||||
limit := 10
|
||||
out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.NilError(c, err)
|
||||
outSlice := strings.Split(out, "\n")
|
||||
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
||||
|
||||
limit = 50
|
||||
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.NilError(c, err)
|
||||
outSlice = strings.Split(out, "\n")
|
||||
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
||||
|
||||
limit = 100
|
||||
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.NilError(c, err)
|
||||
outSlice = strings.Split(out, "\n")
|
||||
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
||||
|
||||
limit = 0
|
||||
_, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.ErrorContains(c, err, "")
|
||||
|
||||
limit = 200
|
||||
_, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.ErrorContains(c, err, "")
|
||||
for _, limit := range []int{-1, 0, 101} {
|
||||
_, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
||||
assert.ErrorContains(c, err, "")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue