summaryrefslogtreecommitdiff
path: root/integration-cli/docker_cli_search_test.go
diff options
context:
space:
mode:
authorYong Tang <yong.tang.github@outlook.com>2016-06-01 13:38:14 -0700
committerYong Tang <yong.tang.github@outlook.com>2016-06-02 19:12:20 -0700
commit92f10fe228c1b4b527b87ac47401132322283ea3 (patch)
tree90ad546bea82893ab79b1ae4713937ad4c80012d /integration-cli/docker_cli_search_test.go
parent98c245c9e63793cf8ca03c5500e0820447c1861c (diff)
downloaddocker-92f10fe228c1b4b527b87ac47401132322283ea3.tar.gz
Add `--limit` option to `docker search`
This fix tries to address the issue raised in #23055. Currently `docker search` result caps at 25 and there is no way to allow getting more results (if exist). This fix adds the flag `--limit` so that it is possible to return more results from the `docker search`. Related documentation has been updated. Additional tests have been added to cover the changes. This fix fixes #23055. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'integration-cli/docker_cli_search_test.go')
-rw-r--r--integration-cli/docker_cli_search_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go
index a93d657265..ba8d0021a7 100644
--- a/integration-cli/docker_cli_search_test.go
+++ b/integration-cli/docker_cli_search_test.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
"strings"
"github.com/docker/docker/pkg/integration/checker"
@@ -97,3 +98,34 @@ func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) {
dockerCmd(c, "search", "ubuntu-")
}
+
+// test case for #23055
+func (s *DockerSuite) TestSearchWithLimit(c *check.C) {
+ testRequires(c, Network, DaemonIsLinux)
+
+ limit := 10
+ out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
+ c.Assert(err, checker.IsNil)
+ outSlice := strings.Split(out, "\n")
+ c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
+
+ limit = 50
+ out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
+ c.Assert(err, checker.IsNil)
+ outSlice = strings.Split(out, "\n")
+ c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
+
+ limit = 100
+ out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
+ c.Assert(err, checker.IsNil)
+ outSlice = strings.Split(out, "\n")
+ c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
+
+ limit = 0
+ out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
+ c.Assert(err, checker.Not(checker.IsNil))
+
+ limit = 200
+ out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
+ c.Assert(err, checker.Not(checker.IsNil))
+}