diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2019-07-17 13:09:17 +0200 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2019-07-17 13:09:17 +0200 |
commit | 2ac55d5c9aa1255a9c9ec4a8b8eaea004fe0c418 (patch) | |
tree | f67f4770f6e8da8c5cfe60497a215f0a10dff20f /integration-cli/docker_cli_search_test.go | |
parent | 85d6fb888c89ff0124b32d7df5485656e2d48b8e (diff) | |
download | docker-2ac55d5c9aa1255a9c9ec4a8b8eaea004fe0c418.tar.gz |
TestSearchWithLimit: slight refactor and improve boundary checks
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'integration-cli/docker_cli_search_test.go')
-rw-r--r-- | integration-cli/docker_cli_search_test.go | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go index e13b48b7a2..f9ec2c3017 100644 --- a/integration-cli/docker_cli_search_test.go +++ b/integration-cli/docker_cli_search_test.go @@ -74,29 +74,15 @@ func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) { func (s *DockerSuite) TestSearchWithLimit(c *check.C) { testRequires(c, Network, DaemonIsLinux) - 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{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 + } + + for _, limit := range []int{-1, 0, 101} { + _, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker") + assert.ErrorContains(c, err, "") + } } |