diff options
author | Yuan Sun <sunyuan3@huawei.com> | 2015-04-14 09:23:26 +0800 |
---|---|---|
committer | Yuan Sun <sunyuan3@huawei.com> | 2015-04-14 09:23:26 +0800 |
commit | 77f2a4a0e373225c145966c96d076d6d9f25b3b3 (patch) | |
tree | 33740303cda28be793324e42c08037e16f4cf18d /integration-cli/docker_cli_search_test.go | |
parent | 24df333fa555bc3768bf6509f06e306bf11b835f (diff) | |
download | docker-77f2a4a0e373225c145966c96d076d6d9f25b3b3.tar.gz |
add TestSearchCmdOptions case
Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
Diffstat (limited to 'integration-cli/docker_cli_search_test.go')
-rw-r--r-- | integration-cli/docker_cli_search_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go index a3546103f3..fcfd9eceb9 100644 --- a/integration-cli/docker_cli_search_test.go +++ b/integration-cli/docker_cli_search_test.go @@ -45,3 +45,53 @@ func TestSearchStarsOptionWithWrongParameter(t *testing.T) { logDone("search - Verify search with wrong parameter.") } + +func TestSearchCmdOptions(t *testing.T) { + testRequires(t, Network) + searchCmdhelp := exec.Command(dockerBinary, "search", "--help") + out, exitCode, err := runCommandWithOutput(searchCmdhelp) + if err != nil || exitCode != 0 { + t.Fatalf("failed to get search help information: %s, %v", out, err) + } + + if !strings.Contains(out, "Usage: docker search [OPTIONS] TERM") { + t.Fatalf("failed to show docker search usage: %s, %v", out, err) + } + + searchCmd := exec.Command(dockerBinary, "search", "busybox") + outSearchCmd, exitCode, err := runCommandWithOutput(searchCmd) + if err != nil || exitCode != 0 { + t.Fatalf("failed to search on the central registry: %s, %v", outSearchCmd, err) + } + + searchCmdautomated := exec.Command(dockerBinary, "search", "--automated=true", "busybox") + outSearchCmdautomated, exitCode, err := runCommandWithOutput(searchCmdautomated) //The busybox is a busybox base image, not an AUTOMATED image. + if err != nil || exitCode != 0 { + t.Fatalf("failed to search with automated=true on the central registry: %s, %v", outSearchCmdautomated, err) + } + + outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n") + for i := range outSearchCmdautomatedSlice { + if strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox ") { + t.Fatalf("The busybox is not an AUTOMATED image: %s, %v", out, err) + } + } + + searchCmdStars := exec.Command(dockerBinary, "search", "-s=2", "busybox") + outSearchCmdStars, exitCode, err := runCommandWithOutput(searchCmdStars) + if err != nil || exitCode != 0 { + t.Fatalf("failed to search with stars=2 on the central registry: %s, %v", outSearchCmdStars, err) + } + + if strings.Count(outSearchCmdStars, "[OK]") > strings.Count(outSearchCmd, "[OK]") { + t.Fatalf("The quantity of images with stars should be less than that of all images: %s, %v", outSearchCmdStars, err) + } + + searchCmdOptions := exec.Command(dockerBinary, "search", "--stars=2", "--automated=true", "--no-trunc=true", "busybox") + out, exitCode, err = runCommandWithOutput(searchCmdOptions) + if err != nil || exitCode != 0 { + t.Fatalf("failed to search with stars&automated&no-trunc options on the central registry: %s, %v", out, err) + } + + logDone("search - have a try for search options.") +} |