rm-gocheck: Not(Contains) -> !strings.Contains

sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Not\(checker\.Contains\), (.*)\)$#assert.Assert(c, !eg_contains(\1, \2))#g' \
-- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" \
&& \
go get -d golang.org/x/tools/cmd/eg && dir=$(go env GOPATH)/src/golang.org/x/tools && git -C "$dir" fetch https://github.com/tiborvass/tools handle-variadic && git -C "$dir" checkout 61a94b82347c29b3289e83190aa3dda74d47abbb && go install golang.org/x/tools/cmd/eg \
&& \
/bin/echo -e 'package main\nvar eg_contains func(arg1, arg2 string, extra ...interface{}) bool' > ./integration-cli/eg_helper.go \
&& \
goimports -w ./integration-cli \
&& \
eg -w -t template.not_contains.go -- ./integration-cli \
&& \
rm -f ./integration-cli/eg_helper.go \
&& \
go run rm-gocheck.go redress '\bassert\.Assert\b.*(\(|,)\s*$' \
 "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2019-09-09 21:07:46 +00:00
parent f2c9e391fc
commit 4e2e486b23
18 changed files with 129 additions and 169 deletions

View file

@ -4657,7 +4657,7 @@ func (s *DockerSuite) TestBuildMultiStageArg(c *testing.T) {
assert.Assert(c, result.Stdout(), checker.Contains, "foo=abc")
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "foo")
assert.Assert(c, !strings.Contains(result.Stdout(), "foo"))
assert.Assert(c, result.Stdout(), checker.Contains, "bar=def")
}
@ -4680,8 +4680,7 @@ func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *testing.T) {
parentID := strings.TrimSpace(result.Stdout())
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "tag")
assert.Assert(c, !strings.Contains(result.Stdout(), "tag"))
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
assert.Assert(c, result.Stdout(), checker.Contains, "tag=latest")
}
@ -4702,8 +4701,8 @@ func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *testing.T) {
assert.Assert(c, result.Combined(), checker.Contains, "[baz] were not consumed")
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "bar")
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "baz")
assert.Assert(c, !strings.Contains(result.Stdout(), "bar"))
assert.Assert(c, !strings.Contains(result.Stdout(), "baz"))
}
func (s *DockerSuite) TestBuildNoNamedVolume(c *testing.T) {
@ -4816,8 +4815,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
assert.NilError(c, err)
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache")
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
assert.Assert(c, cmp.Regexp("^"+
@ -4858,8 +4856,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
assert.NilError(c, err)
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache")
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
assert.Assert(c, cmp.Regexp("^"+
@ -4919,7 +4916,7 @@ func (s *DockerSuite) TestBuildCacheRootSource(c *testing.T) {
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache")
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
}
// #19375
@ -5073,8 +5070,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestBuildWithExternalAuth(c *testing.T
b, err := ioutil.ReadFile(configPath)
assert.NilError(c, err)
assert.Assert(c, string(b), checker.Not(checker.Contains), "\"auth\":")
assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)
@ -5432,8 +5428,8 @@ func (s *DockerSuite) TestBuildWithFailure(c *testing.T) {
dockerfile = "FFOM nobody\nRUN nobody"
result = buildImage(name, build.WithDockerfile(dockerfile))
assert.Assert(c, result.Error != nil)
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "Step 1/2 : FROM busybox")
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "Step 2/2 : RUN nobody")
assert.Assert(c, !strings.Contains(result.Stdout(), "Step 1/2 : FROM busybox"))
assert.Assert(c, !strings.Contains(result.Stdout(), "Step 2/2 : RUN nobody"))
}
func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *testing.T) {

View file

@ -235,7 +235,7 @@ func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *testing.T) {
dockerCmd(c, "pull", imageReference)
out, _ := dockerCmd(c, "images")
assert.Assert(c, out, checker.Not(checker.Contains), "DIGEST", check.Commentf("list output should not have contained DIGEST header"))
assert.Assert(c, !strings.Contains(out, "DIGEST"), check.Commentf("list output should not have contained DIGEST header"))
}
func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {

View file

@ -322,7 +322,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) {
assert.Assert(c, is.Contains(out, "unknown log opt"))
out, _ = dockerCmd(c, "ps", "-a")
assert.Assert(c, out, checker.Not(checker.Contains), name)
assert.Assert(c, !strings.Contains(out, name))
}
// #20972

View file

@ -2113,12 +2113,11 @@ func (s *DockerDaemonSuite) TestRunLinksChanged(c *testing.T) {
assert.NilError(c, err, out)
out, err = s.d.Cmd("start", "-a", "test2")
assert.ErrorContains(c, err, "", out)
assert.Assert(c, out, checker.Not(checker.Contains), "1 packets transmitted, 1 packets received")
assert.Assert(c, !strings.Contains(out, "1 packets transmitted, 1 packets received"))
s.d.Restart(c)
out, err = s.d.Cmd("start", "-a", "test2")
assert.ErrorContains(c, err, "", out)
assert.Assert(c, out, checker.Not(checker.Contains), "1 packets transmitted, 1 packets received")
assert.Assert(c, !strings.Contains(out, "1 packets transmitted, 1 packets received"))
}
func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) {
@ -2168,7 +2167,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) {
// Wait for io.Copy() before checking output
<-done
assert.Assert(c, b.String() != "")
assert.Assert(c, b.String(), checker.Not(checker.Contains), infoLog)
assert.Assert(c, !strings.Contains(b.String(), infoLog))
}
func (s *DockerDaemonSuite) TestDaemonDebugLog(c *testing.T) {
@ -2587,7 +2586,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *testing.
out, err = s.d.Cmd("ps", "-a")
assert.NilError(c, err, "out: %v", out)
assert.Assert(c, out, checker.Contains, "top1", check.Commentf("top1 should exist after daemon restarts"))
assert.Assert(c, out, checker.Not(checker.Contains), "top2", check.Commentf("top2 should be removed after daemon restarts"))
assert.Assert(c, !strings.Contains(out, "top2"), check.Commentf("top2 should be removed after daemon restarts"))
}
func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *testing.T) {

View file

@ -34,9 +34,8 @@ func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) {
imagesOut, _ := dockerCmd(c, "images", name+":v1")
assert.Assert(c, imagesOut, checker.Contains, name)
assert.Assert(c, imagesOut, checker.Contains, "v1")
assert.Assert(c, imagesOut, checker.Not(checker.Contains), "v2")
assert.Assert(c, imagesOut, checker.Not(checker.Contains), "v1v1")
assert.Assert(c, !strings.Contains(imagesOut, "v2"))
assert.Assert(c, !strings.Contains(imagesOut, "v1v1"))
imagesOut, _ = dockerCmd(c, "images", name)
assert.Assert(c, imagesOut, checker.Contains, name)
assert.Assert(c, imagesOut, checker.Contains, "v1")
@ -46,7 +45,7 @@ func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) {
func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *testing.T) {
imagesOut, _ := dockerCmd(c, "images", "busybox:nonexistent")
assert.Assert(c, imagesOut, checker.Not(checker.Contains), "busybox")
assert.Assert(c, !strings.Contains(imagesOut, "busybox"))
}
func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) {
@ -256,8 +255,7 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T)
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=false")
//dangling=false would not include dangling images
assert.Assert(c, out, checker.Not(checker.Contains), imageID)
assert.Assert(c, !strings.Contains(out, imageID))
out, _ = dockerCmd(c, "images")
//docker images still include dangling images
assert.Assert(c, out, checker.Contains, imageID)
@ -289,7 +287,7 @@ func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) {
out, _ := dockerCmd(c, "images")
// images shouldn't show non-heads images
assert.Assert(c, out, checker.Not(checker.Contains), intermediate)
assert.Assert(c, !strings.Contains(out, intermediate))
// images should contain final built images
assert.Assert(c, out, checker.Contains, stringid.TruncateID(id))
}
@ -336,7 +334,7 @@ func (s *DockerSuite) TestImagesFilterNameWithPort(c *testing.T) {
assert.Assert(c, out, checker.Contains, tag)
out, _ = dockerCmd(c, "images", tag+":no-such-tag")
assert.Assert(c, out, checker.Not(checker.Contains), tag)
assert.Assert(c, !strings.Contains(out, tag))
}
func (s *DockerSuite) TestImagesFormat(c *testing.T) {

View file

@ -110,7 +110,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) {
out, _ := dockerCmd(c, "inspect", "--type=image", "busybox")
// not an image JSON
assert.Assert(c, out, checker.Not(checker.Contains), "State")
assert.Assert(c, !strings.Contains(out, "State"))
}
func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) {

View file

@ -1260,13 +1260,11 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine
// Test disconnect
dockerCmd(c, "network", "disconnect", "test", "foo")
networks = inspectField(c, "foo", "NetworkSettings.Networks")
assert.Assert(c, networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
assert.Assert(c, !strings.Contains(networks, "test"), check.Commentf("Should not contain 'test' network"))
// Restart docker daemon to test the config has persisted to disk
s.d.Restart(c)
networks = inspectField(c, "foo", "NetworkSettings.Networks")
assert.Assert(c, networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
assert.Assert(c, !strings.Contains(networks, "test"), check.Commentf("Should not contain 'test' network"))
}
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetwork(c *testing.T) {
@ -1282,7 +1280,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetw
// Test disconnecting stopped container from nonexisting network
dockerCmd(c, "network", "disconnect", "-f", "test", "foo")
networks = inspectField(c, "foo", "NetworkSettings.Networks")
assert.Assert(c, networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
assert.Assert(c, !strings.Contains(networks, "test"), check.Commentf("Should not contain 'test' network"))
}
func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
@ -1497,7 +1495,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *testing.T) {
networks := inspectField(c, containerName, "NetworkSettings.Networks")
assert.Assert(c, networks, checker.Contains, netWorkName1, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName1)))
assert.Assert(c, networks, checker.Contains, netWorkName2, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName2)))
assert.Assert(c, networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network"))
assert.Assert(c, !strings.Contains(networks, "bridge"), check.Commentf("Should not contain 'bridge' network"))
}
func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *testing.T) {

View file

@ -407,7 +407,7 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
// List returns none
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
assert.Assert(c, out, checker.Not(checker.Contains), name)
assert.Assert(c, !strings.Contains(out, name))
}
func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {

View file

@ -97,8 +97,7 @@ func (s *DockerDaemonSuite) TestPruneImageDangling(c *testing.T) {
out, err = s.d.Cmd("image", "prune", "--force")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id))
out, err = s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id)
@ -109,7 +108,7 @@ func (s *DockerDaemonSuite) TestPruneImageDangling(c *testing.T) {
out, err = s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id))
}
func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) {
@ -125,10 +124,9 @@ func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) {
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "until="+until).Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
}
@ -159,35 +157,33 @@ func (s *DockerSuite) TestPruneContainerLabel(c *testing.T) {
// With config.json only, prune based on label=foobar
out = cli.DockerCmd(c, "--config", d, "container", "prune", "--force").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id3)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id4)
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "label=foo").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id3)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "label!=bar").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id3)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
// With config.json label=foobar and CLI label!=foobar, CLI label!=foobar supersede
out = cli.DockerCmd(c, "--config", d, "container", "prune", "--force", "--filter", "label!=foobar").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
}
func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) {
@ -217,35 +213,33 @@ func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) {
// With config.json only, prune based on label=foobar
out, _ = dockerCmd(c, "--config", d, "volume", "prune", "--force")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id3)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id4)
out, _ = dockerCmd(c, "volume", "prune", "--force", "--filter", "label=foo")
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id3)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
out, _ = dockerCmd(c, "volume", "prune", "--force", "--filter", "label!=bar")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id3)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
// With config.json label=foobar and CLI label!=foobar, CLI label!=foobar supersede
out, _ = dockerCmd(c, "--config", d, "volume", "prune", "--force", "--filter", "label!=foobar")
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
}
func (s *DockerSuite) TestPruneNetworkLabel(c *testing.T) {
@ -255,18 +249,17 @@ func (s *DockerSuite) TestPruneNetworkLabel(c *testing.T) {
out, _ := dockerCmd(c, "network", "prune", "--force", "--filter", "label=foo")
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "n1")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n2")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n3")
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n2"))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n3"))
out, _ = dockerCmd(c, "network", "prune", "--force", "--filter", "label!=bar")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n1")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n2")
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n1"))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n2"))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "n3")
out, _ = dockerCmd(c, "network", "prune", "--force")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n1")
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n1"))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "n2")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n3")
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n3"))
}
func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
@ -297,15 +290,13 @@ func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label=foo=bar")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label!=bar=foo")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label=bar=foo")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id1)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
}

View file

@ -434,7 +434,7 @@ func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) {
containerOut = strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Contains, firstID)
assert.Assert(c, containerOut, checker.Contains, secondID)
assert.Assert(c, containerOut, checker.Not(checker.Contains), thirdID)
assert.Assert(c, !strings.Contains(containerOut, thirdID))
}
func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) {
@ -455,14 +455,13 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) {
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=exited=0")
assert.Assert(c, out, checker.Contains, strings.TrimSpace(firstZero))
assert.Assert(c, out, checker.Contains, strings.TrimSpace(secondZero))
assert.Assert(c, out, checker.Not(checker.Contains), strings.TrimSpace(firstNonZero))
assert.Assert(c, out, checker.Not(checker.Contains), strings.TrimSpace(secondNonZero))
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(firstNonZero)))
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(secondNonZero)))
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=exited=1")
assert.Assert(c, out, checker.Contains, strings.TrimSpace(firstNonZero))
assert.Assert(c, out, checker.Contains, strings.TrimSpace(secondNonZero))
assert.Assert(c, out, checker.Not(checker.Contains), strings.TrimSpace(firstZero))
assert.Assert(c, out, checker.Not(checker.Contains), strings.TrimSpace(secondZero))
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(firstZero)))
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(secondZero)))
}
func (s *DockerSuite) TestPsRightTagName(c *testing.T) {
@ -519,8 +518,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) {
// Make sure it DOESN'T show up w/o a '-a' for normal 'ps'
out, _ = dockerCmd(c, "ps", "-q")
assert.Assert(c, out, checker.Not(checker.Contains), shortCID, check.Commentf("Should have not seen '%s' in ps output:\n%s", shortCID, out))
assert.Assert(c, !strings.Contains(out, shortCID), check.Commentf("Should have not seen '%s' in ps output:\n%s", shortCID, out))
// Make sure it DOES show up as 'Created' for 'ps -a'
out, _ = dockerCmd(c, "ps", "-a")

View file

@ -396,8 +396,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithSchem
b, err := ioutil.ReadFile(configPath)
assert.NilError(c, err)
assert.Assert(c, string(b), checker.Not(checker.Contains), "\"auth\":")
assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)
@ -441,8 +440,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *testing.T)
b, err := ioutil.ReadFile(configPath)
assert.NilError(c, err)
assert.Assert(c, string(b), checker.Not(checker.Contains), "\"auth\":")
assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)

View file

@ -102,7 +102,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *testing.T) {
imagesAfter = cli.DockerCmd(c, "images", "-a").Combined()
// rmi -f failed, image still exists
assert.Assert(c, imagesAfter, checker.Not(checker.Contains), imgID[:12], check.Commentf("ImageID:%q; ImagesAfter: %q", imgID, imagesAfter))
assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]), check.Commentf("ImageID:%q; ImagesAfter: %q", imgID, imagesAfter))
}
func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) {
@ -138,7 +138,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) {
{
imagesAfter := cli.DockerCmd(c, "images", "-a").Combined()
// rmi failed, image still exists
assert.Assert(c, imagesAfter, checker.Not(checker.Contains), imgID[:12])
assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]))
}
}
@ -209,8 +209,7 @@ func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) {
out, _ := dockerCmd(c, "rmi", "-f", tag2)
assert.Assert(c, out, checker.Contains, "Untagged: "+tag2)
assert.Assert(c, out, checker.Not(checker.Contains), "Untagged: "+tag1)
assert.Assert(c, !strings.Contains(out, "Untagged: "+tag1))
// Check built image still exists
images, _ := dockerCmd(c, "images", "-a")
assert.Assert(c, images, checker.Contains, imageName, check.Commentf("Built image missing %q; Images: %q", imageName, images))
@ -221,7 +220,7 @@ func (s *DockerSuite) TestRmiBlank(c *testing.T) {
// Should have failed to delete ' ' image
assert.ErrorContains(c, err, "")
// Wrong error message generated
assert.Assert(c, out, checker.Not(checker.Contains), "no such id", check.Commentf("out: %s", out))
assert.Assert(c, !strings.Contains(out, "no such id"), check.Commentf("out: %s", out))
// Expected error message not generated
assert.Assert(c, out, checker.Contains, "image name cannot be blank", check.Commentf("out: %s", out))
}

View file

@ -3921,7 +3921,7 @@ func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) {
dockerCmd(c, "volume", "inspect", "test")
out, _ := dockerCmd(c, "volume", "ls", "-q")
assert.Assert(c, strings.Contains(out, "test"))
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), vname)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), vname))
}
func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
@ -4199,7 +4199,7 @@ func (s *DockerSuite) TestRunDuplicateMount(c *testing.T) {
name := "test"
out, _ := dockerCmd(c, "run", "--name", name, "-v", "/tmp:/tmp", "-v", "/tmp:/tmp", "busybox", "sh", "-c", "cat "+tmpFile.Name()+" && ls /")
assert.Assert(c, out, checker.Not(checker.Contains), "tmp:")
assert.Assert(c, !strings.Contains(out, "tmp:"))
assert.Assert(c, out, checker.Contains, data)
out = inspectFieldJSON(c, name, "Config.Volumes")

View file

@ -847,7 +847,7 @@ func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *testing.T) {
RUN touch /run/stuff
`))
out, _ := dockerCmd(c, "run", "--tmpfs", "/run", name, "ls", "/run")
assert.Assert(c, out, checker.Not(checker.Contains), "stuff")
assert.Assert(c, !strings.Contains(out, "stuff"))
}
// Test case for #22420
@ -859,15 +859,13 @@ func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) {
for _, option := range expectedOptions {
assert.Assert(c, out, checker.Contains, option)
}
assert.Assert(c, out, checker.Not(checker.Contains), "size=")
assert.Assert(c, !strings.Contains(out, "size="))
expectedOptions = []string{"rw", "nosuid", "nodev", "noexec", "relatime"}
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
for _, option := range expectedOptions {
assert.Assert(c, out, checker.Contains, option)
}
assert.Assert(c, out, checker.Not(checker.Contains), "size=")
assert.Assert(c, !strings.Contains(out, "size="))
expectedOptions = []string{"rw", "nosuid", "nodev", "relatime", "size=8192k"}
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw,exec,size=8192k", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
for _, option := range expectedOptions {

View file

@ -394,7 +394,7 @@ func (s *DockerSuite) TestSaveLoadNoTag(c *testing.T) {
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
// Should not show 'name' but should show the image ID during the load
assert.Assert(c, out, checker.Not(checker.Contains), "Loaded image: ")
assert.Assert(c, !strings.Contains(out, "Loaded image: "))
assert.Assert(c, out, checker.Contains, "Loaded image ID:")
assert.Assert(c, out, checker.Contains, id)
@ -405,5 +405,5 @@ func (s *DockerSuite) TestSaveLoadNoTag(c *testing.T) {
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
assert.Assert(c, out, checker.Contains, "Loaded image: "+name+":latest")
assert.Assert(c, out, checker.Not(checker.Contains), "Loaded image ID:")
assert.Assert(c, !strings.Contains(out, "Loaded image ID:"))
}

View file

@ -185,7 +185,7 @@ func (s *DockerSuite) TestStartAttachWithRename(c *testing.T) {
result := cli.Docker(cli.Args("start", "-a", "before")).Assert(c, icmd.Expected{
ExitCode: 137,
})
assert.Assert(c, result.Stderr(), checker.Not(checker.Contains), "No such container")
assert.Assert(c, !strings.Contains(result.Stderr(), "No such container"))
}
func (s *DockerSuite) TestStartReturnCorrectExitCode(c *testing.T) {

View file

@ -212,15 +212,13 @@ func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *testing.T) {
out, err = d.Cmd("service", "ls", "--filter", filter1)
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, name1+" ")
assert.Assert(c, out, checker.Not(checker.Contains), name2+" ")
assert.Assert(c, out, checker.Not(checker.Contains), name3+" ")
assert.Assert(c, !strings.Contains(out, name2+" "))
assert.Assert(c, !strings.Contains(out, name3+" "))
out, err = d.Cmd("service", "ls", "--filter", filter2)
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, name1+" ")
assert.Assert(c, out, checker.Contains, name2+" ")
assert.Assert(c, out, checker.Not(checker.Contains), name3+" ")
assert.Assert(c, !strings.Contains(out, name3+" "))
out, err = d.Cmd("service", "ls")
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, name1+" ")
@ -244,7 +242,7 @@ func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
out, err = d.Cmd("node", "ls", "--filter", "name=none")
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Not(checker.Contains), name)
assert.Assert(c, !strings.Contains(out, name))
}
func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
@ -268,9 +266,9 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
out, err = d.Cmd("node", "ps", "--filter", "name=none", "self")
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Not(checker.Contains), name+".1")
assert.Assert(c, out, checker.Not(checker.Contains), name+".2")
assert.Assert(c, out, checker.Not(checker.Contains), name+".3")
assert.Assert(c, !strings.Contains(out, name+".1"))
assert.Assert(c, !strings.Contains(out, name+".2"))
assert.Assert(c, !strings.Contains(out, name+".3"))
}
// Test case for #25375
@ -442,7 +440,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *testing.T) {
// Check the network is gone
out, err = d.Cmd("network", "ls", "--format", "{{.Name}}")
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Not(checker.Contains), nwName)
assert.Assert(c, !strings.Contains(out, nwName))
}
func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *testing.T) {
@ -570,15 +568,13 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
out, err = d.Cmd("service", "ps", "--filter", "name="+name+".1", name)
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, name+".1")
assert.Assert(c, out, checker.Not(checker.Contains), name+".2")
assert.Assert(c, out, checker.Not(checker.Contains), name+".3")
assert.Assert(c, !strings.Contains(out, name+".2"))
assert.Assert(c, !strings.Contains(out, name+".3"))
out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Not(checker.Contains), name+".1")
assert.Assert(c, out, checker.Not(checker.Contains), name+".2")
assert.Assert(c, out, checker.Not(checker.Contains), name+".3")
assert.Assert(c, !strings.Contains(out, name+".1"))
assert.Assert(c, !strings.Contains(out, name+".2"))
assert.Assert(c, !strings.Contains(out, name+".3"))
name = "redis-cluster-sha1"
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "--mode=global", "busybox", "top")
assert.NilError(c, err, out)
@ -597,7 +593,7 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Not(checker.Contains), name)
assert.Assert(c, !strings.Contains(out, name))
}
func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
@ -1041,8 +1037,7 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
ExitCode: 1,
})
assert.Assert(c, result.Combined(), checker.Contains, "Error: This node is not part of a swarm")
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Please enter unlock key")
assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
out, err := d.Cmd("swarm", "init")
assert.NilError(c, err, out)
@ -1053,7 +1048,7 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
ExitCode: 1,
})
assert.Assert(c, result.Combined(), checker.Contains, "Error: swarm is not locked")
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Please enter unlock key")
assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
}
func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
@ -1086,8 +1081,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
outs, err = d.Cmd("node", "ls")
assert.Assert(c, err == nil, check.Commentf("%s", outs))
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
outs, err = d.Cmd("swarm", "update", "--autolock=false")
assert.Assert(c, err == nil, check.Commentf("%s", outs))
@ -1095,7 +1089,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
outs, err = d.Cmd("node", "ls")
assert.Assert(c, err == nil, check.Commentf("%s", outs))
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
}
func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
@ -1320,7 +1314,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
}
}
assert.NilError(c, err)
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
break
}
@ -1412,7 +1406,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
}
}
assert.Assert(c, err == nil, check.Commentf("%s", outs))
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
break
}
}
@ -1584,8 +1578,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
out, err := d.Cmd("node", "ls")
assert.NilError(c, err)
assert.Assert(c, out, checker.Not(checker.Contains), "Drain")
assert.Assert(c, !strings.Contains(out, "Drain"))
out, err = d.Cmd("swarm", "join-token", "-q", "manager")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out) != "")
@ -1750,17 +1743,16 @@ func (s *DockerSwarmSuite) TestSwarmServiceLsFilterMode(c *testing.T) {
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, "top1")
assert.Assert(c, out, checker.Contains, "top2")
assert.Assert(c, out, checker.Not(checker.Contains), "localnet")
assert.Assert(c, !strings.Contains(out, "localnet"))
out, err = d.Cmd("service", "ls", "--filter", "mode=global")
assert.Assert(c, out, checker.Not(checker.Contains), "top1")
assert.Assert(c, !strings.Contains(out, "top1"))
assert.Assert(c, out, checker.Contains, "top2")
assert.NilError(c, err, out)
out, err = d.Cmd("service", "ls", "--filter", "mode=replicated")
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, "top1")
assert.Assert(c, out, checker.Not(checker.Contains), "top2")
assert.Assert(c, !strings.Contains(out, "top2"))
}
func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *testing.T) {
@ -1842,7 +1834,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *testing.T) {
// d3 is a worker, not able to get cluster events
out = waitForEvent(c, d3, "0", "-f scope=swarm", "", 1)
assert.Assert(c, out, checker.Not(checker.Contains), "network create ")
assert.Assert(c, !strings.Contains(out, "network create "))
}
func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *testing.T) {
@ -1855,15 +1847,14 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *testing.T) {
// scope swarm filters cluster events
out = waitForEvent(c, d, "0", "-f scope=swarm", "service create "+serviceID, defaultRetryCount)
assert.Assert(c, out, checker.Not(checker.Contains), "container create ")
assert.Assert(c, !strings.Contains(out, "container create "))
// all events are returned if scope is not specified
waitForEvent(c, d, "0", "", "service create "+serviceID, 1)
waitForEvent(c, d, "0", "", "container create ", defaultRetryCount)
// scope local only shows non-cluster events
out = waitForEvent(c, d, "0", "-f scope=local", "container create ", 1)
assert.Assert(c, out, checker.Not(checker.Contains), "service create ")
assert.Assert(c, !strings.Contains(out, "service create "))
}
func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *testing.T) {
@ -1882,11 +1873,10 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *testing.T) {
// filter by service
out = waitForEvent(c, d, "0", "-f type=service", "service create "+serviceID, defaultRetryCount)
assert.Assert(c, out, checker.Not(checker.Contains), "network create")
assert.Assert(c, !strings.Contains(out, "network create"))
// filter by network
out = waitForEvent(c, d, "0", "-f type=network", "network create "+networkID, defaultRetryCount)
assert.Assert(c, out, checker.Not(checker.Contains), "service create")
assert.Assert(c, !strings.Contains(out, "service create"))
}
func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *testing.T) {

View file

@ -142,7 +142,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) {
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=false")
// Explicitly disabling dangling
assert.Assert(c, out, checker.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
@ -150,23 +150,21 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) {
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output
assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected"))
assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected"))
assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), check.Commentf("volume 'testisinuse1' in output, but not expected"))
assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), check.Commentf("volume 'testisinuse2' in output, but not expected"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=1")
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output, dangling also accept 1
assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected"))
assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected"))
assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), check.Commentf("volume 'testisinuse1' in output, but not expected"))
assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), check.Commentf("volume 'testisinuse2' in output, but not expected"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=0")
// dangling=0 is same as dangling=false case
assert.Assert(c, out, checker.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "name=testisin")
assert.Assert(c, out, checker.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
}
@ -330,8 +328,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) {
// filter with label=key=value
assert.Assert(c, out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
assert.Assert(c, out, checker.Not(checker.Contains), "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2 in output"))
assert.Assert(c, !strings.Contains(out, "testvolcreatelabel-2\n"), check.Commentf("expected volume 'testvolcreatelabel-2 in output"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=non-exist")
outArr := strings.Split(strings.TrimSpace(out), "\n")
assert.Equal(c, len(outArr), 1, check.Commentf("\n%s", out))
@ -396,7 +393,7 @@ func (s *DockerSuite) TestVolumeCLIRmForce(c *testing.T) {
dockerCmd(c, "volume", "rm", "-f", name)
out, _ = dockerCmd(c, "volume", "ls")
assert.Assert(c, out, checker.Not(checker.Contains), name)
assert.Assert(c, !strings.Contains(out, name))
dockerCmd(c, "volume", "create", name)
out, _ = dockerCmd(c, "volume", "ls")
assert.Assert(c, out, checker.Contains, name)
@ -439,7 +436,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
out, e = dockerCmd(c, "volume", "ls")
assert.Equal(c, e, 0)
assert.Assert(c, out, checker.Not(checker.Contains), name)
assert.Assert(c, !strings.Contains(out, name))
}
func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) {
@ -501,8 +498,8 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) {
// Both volume should not exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
}
// Test case (2) for 21845: duplicate targets for --volumes-from and -v (bind)
@ -536,17 +533,16 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T
// No volume will be referenced (mount is /tmp/data), this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
dockerCmd(c, "rm", "-f", "-v", "app")
dockerCmd(c, "rm", "-f", "-v", "data1")
dockerCmd(c, "rm", "-f", "-v", "data2")
// Both volume should not exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
}
// Test case (3) for 21845: duplicate targets for --volumes-from and `Mounts` (API only)
@ -602,15 +598,14 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *testing
// No volume will be referenced (mount is /tmp/data), this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
dockerCmd(c, "rm", "-f", "-v", "app")
dockerCmd(c, "rm", "-f", "-v", "data1")
dockerCmd(c, "rm", "-f", "-v", "data2")
// Both volume should not exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data1)
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), data2)
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
}