2014-02-25 11:17:48 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2015-04-18 12:46:47 -04:00
|
|
|
|
|
|
|
"github.com/go-check/check"
|
2014-02-25 11:17:48 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// search for repos named "registry" on the central registry
|
2015-04-18 12:46:47 -04:00
|
|
|
func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) {
|
2015-08-28 13:36:42 -04:00
|
|
|
testRequires(c, Network, DaemonIsLinux)
|
2015-07-21 14:01:24 -04:00
|
|
|
|
|
|
|
out, exitCode := dockerCmd(c, "search", "busybox")
|
|
|
|
if exitCode != 0 {
|
|
|
|
c.Fatalf("failed to search on the central registry: %s", out)
|
2014-02-25 11:17:48 -05:00
|
|
|
}
|
|
|
|
|
2014-06-24 17:16:34 -04:00
|
|
|
if !strings.Contains(out, "Busybox base image.") {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatal("couldn't find any repository named (or containing) 'Busybox base image.'")
|
2014-02-25 11:17:48 -05:00
|
|
|
}
|
|
|
|
}
|
2015-04-02 20:55:08 -04:00
|
|
|
|
2015-04-18 12:46:47 -04:00
|
|
|
func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) {
|
2015-07-27 14:13:25 -04:00
|
|
|
out, exitCode, err := dockerCmdWithError("search", "--stars=a", "busybox")
|
2015-04-02 20:55:08 -04:00
|
|
|
if err == nil || exitCode == 0 {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatalf("Should not get right information: %s, %v", out, err)
|
2015-04-02 20:55:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(out, "invalid value") {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatal("couldn't find the invalid value warning")
|
2015-04-02 20:55:08 -04:00
|
|
|
}
|
|
|
|
|
2015-07-27 14:13:25 -04:00
|
|
|
out, exitCode, err = dockerCmdWithError("search", "-s=-1", "busybox")
|
2015-04-02 20:55:08 -04:00
|
|
|
if err == nil || exitCode == 0 {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatalf("Should not get right information: %s, %v", out, err)
|
2015-04-02 20:55:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(out, "invalid value") {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatal("couldn't find the invalid value warning")
|
2015-04-02 20:55:08 -04:00
|
|
|
}
|
|
|
|
}
|
2015-04-13 21:23:26 -04:00
|
|
|
|
2015-04-18 12:46:47 -04:00
|
|
|
func (s *DockerSuite) TestSearchCmdOptions(c *check.C) {
|
|
|
|
testRequires(c, Network)
|
2015-07-21 14:01:24 -04:00
|
|
|
|
|
|
|
out, exitCode := dockerCmd(c, "search", "--help")
|
|
|
|
if exitCode != 0 {
|
|
|
|
c.Fatalf("failed to get search help information: %s", out)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
|
2015-05-13 22:45:01 -04:00
|
|
|
if !strings.Contains(out, "Usage:\tdocker search [OPTIONS] TERM") {
|
2015-07-21 14:01:24 -04:00
|
|
|
c.Fatalf("failed to show docker search usage: %s", out)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 14:01:24 -04:00
|
|
|
outSearchCmd, exitCode := dockerCmd(c, "search", "busybox")
|
|
|
|
if exitCode != 0 {
|
|
|
|
c.Fatalf("failed to search on the central registry: %s", outSearchCmd)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 14:01:24 -04:00
|
|
|
outSearchCmdNotrunc, _ := dockerCmd(c, "search", "--no-trunc=true", "busybox")
|
2015-05-04 20:51:13 -04:00
|
|
|
|
|
|
|
if len(outSearchCmd) > len(outSearchCmdNotrunc) {
|
|
|
|
c.Fatalf("The no-trunc option can't take effect.")
|
|
|
|
}
|
|
|
|
|
2015-07-21 14:01:24 -04:00
|
|
|
outSearchCmdautomated, exitCode := dockerCmd(c, "search", "--automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image.
|
|
|
|
if exitCode != 0 {
|
|
|
|
c.Fatalf("failed to search with automated=true on the central registry: %s", outSearchCmdautomated)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n")
|
|
|
|
for i := range outSearchCmdautomatedSlice {
|
|
|
|
if strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox ") {
|
2015-07-21 14:01:24 -04:00
|
|
|
c.Fatalf("The busybox is not an AUTOMATED image: %s", out)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 14:01:24 -04:00
|
|
|
outSearchCmdStars, exitCode := dockerCmd(c, "search", "-s=2", "busybox")
|
|
|
|
if exitCode != 0 {
|
|
|
|
c.Fatalf("failed to search with stars=2 on the central registry: %s", outSearchCmdStars)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if strings.Count(outSearchCmdStars, "[OK]") > strings.Count(outSearchCmd, "[OK]") {
|
2015-07-21 14:01:24 -04:00
|
|
|
c.Fatalf("The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 14:01:24 -04:00
|
|
|
out, exitCode = dockerCmd(c, "search", "--stars=2", "--automated=true", "--no-trunc=true", "busybox")
|
|
|
|
if exitCode != 0 {
|
|
|
|
c.Fatalf("failed to search with stars&automated&no-trunc options on the central registry: %s", out)
|
2015-04-13 21:23:26 -04:00
|
|
|
}
|
|
|
|
}
|