2014-02-25 16:17:48 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-06-01 20:38:14 +00:00
|
|
|
"fmt"
|
2014-02-25 16:17:48 +00:00
|
|
|
"strings"
|
2015-04-18 16:46:47 +00:00
|
|
|
|
|
|
|
"github.com/go-check/check"
|
2019-04-04 13:23:19 +00:00
|
|
|
"gotest.tools/assert"
|
2014-02-25 16:17:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// search for repos named "registry" on the central registry
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, Network, DaemonIsLinux)
|
2015-07-21 18:01:24 +00:00
|
|
|
|
2015-10-05 04:01:58 +00:00
|
|
|
out, _ := dockerCmd(c, "search", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Assert(c, strings.Contains(out, "Busybox base image."), "couldn't find any repository named (or containing) 'Busybox base image.'")
|
2014-02-25 16:17:48 +00:00
|
|
|
}
|
2015-04-03 00:55:08 +00:00
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) {
|
2016-05-20 11:41:28 +00:00
|
|
|
out, _, err := dockerCmdWithError("search", "--filter", "stars=a", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
|
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
|
2016-05-20 11:41:28 +00:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("search", "-f", "stars=a", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
|
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
|
2016-05-20 11:41:28 +00:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("search", "-f", "is-automated=a", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
|
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
|
2016-05-20 11:41:28 +00:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("search", "-f", "is-official=a", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
|
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
|
2016-05-20 11:41:28 +00:00
|
|
|
|
|
|
|
// -s --stars deprecated since Docker 1.13
|
|
|
|
out, _, err = dockerCmdWithError("search", "--stars=a", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
|
assert.Assert(c, strings.Contains(out, "invalid syntax"), "couldn't find the invalid value warning")
|
2015-04-03 00:55:08 +00:00
|
|
|
|
2016-05-20 11:41:28 +00:00
|
|
|
// -s --stars deprecated since Docker 1.13
|
2015-10-05 04:01:58 +00:00
|
|
|
out, _, err = dockerCmdWithError("search", "-s=-1", "busybox")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
|
assert.Assert(c, strings.Contains(out, "invalid syntax"), "couldn't find the invalid value warning")
|
2015-04-03 00:55:08 +00:00
|
|
|
}
|
2015-04-14 01:23:26 +00:00
|
|
|
|
2015-09-22 11:44:40 +00:00
|
|
|
// search for repos which start with "ubuntu-" on the central registry
|
|
|
|
func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) {
|
|
|
|
testRequires(c, Network, DaemonIsLinux)
|
|
|
|
|
2015-10-05 04:01:58 +00:00
|
|
|
dockerCmd(c, "search", "ubuntu-")
|
2015-09-22 11:44:40 +00:00
|
|
|
}
|
2016-06-01 20:38:14 +00:00
|
|
|
|
|
|
|
// 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")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-06-01 20:38:14 +00:00
|
|
|
outSlice := strings.Split(out, "\n")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
2016-06-01 20:38:14 +00:00
|
|
|
|
|
|
|
limit = 50
|
|
|
|
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-06-01 20:38:14 +00:00
|
|
|
outSlice = strings.Split(out, "\n")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
2016-06-01 20:38:14 +00:00
|
|
|
|
|
|
|
limit = 100
|
|
|
|
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-06-01 20:38:14 +00:00
|
|
|
outSlice = strings.Split(out, "\n")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Equal(c, len(outSlice), limit+2) // 1 header, 1 carriage return
|
2016-06-01 20:38:14 +00:00
|
|
|
|
|
|
|
limit = 0
|
2017-01-18 02:08:31 +00:00
|
|
|
_, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2016-06-01 20:38:14 +00:00
|
|
|
|
|
|
|
limit = 200
|
2017-01-18 02:08:31 +00:00
|
|
|
_, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2016-06-01 20:38:14 +00:00
|
|
|
}
|