rm-gocheck: Equals -> assert.Equal

sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Equals, (.*)#assert.Equal(c, \1, \2#g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_swarm_node_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_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_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 6dc7f4c167)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Tibor Vass 2019-09-09 21:05:56 +00:00 committed by Sebastiaan van Stijn
parent b3d02e7f3c
commit 6dc7846d26
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
34 changed files with 538 additions and 538 deletions

View file

@ -53,7 +53,7 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *testing.T) {
assert.NilError(c, err)
assert.Equal(c, len(containers), startCount+1)
actual := containers[0].Names[0]
assert.Assert(c, actual, checker.Equals, "/"+name)
assert.Equal(c, actual, "/"+name)
}
// regression test for empty json field being omitted #13691
@ -411,8 +411,8 @@ func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
c.Fatalf("expected `USER` at `Titles[0]` and `COMMAND` at Titles[10]: %v", top.Titles)
}
assert.Assert(c, top.Processes, checker.HasLen, 2, check.Commentf("expected 2 processes, found %d: %v", len(top.Processes), top.Processes))
assert.Assert(c, top.Processes[0][10], checker.Equals, "/bin/sh -c top")
assert.Assert(c, top.Processes[1][10], checker.Equals, "top")
assert.Equal(c, top.Processes[0][10], "/bin/sh -c top")
assert.Equal(c, top.Processes[1][10], "top")
}
func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) {
@ -462,7 +462,7 @@ func (s *DockerSuite) TestContainerAPICommit(c *testing.T) {
assert.NilError(c, err)
cmd := inspectField(c, img.ID, "Config.Cmd")
assert.Assert(c, cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd))
assert.Equal(c, cmd, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd))
// sanity check, make sure the image is what we think it is
dockerCmd(c, "run", img.ID, "ls", "/test")
@ -488,13 +488,13 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
assert.NilError(c, err)
label1 := inspectFieldMap(c, img.ID, "Config.Labels", "key1")
assert.Assert(c, label1, checker.Equals, "value1")
assert.Equal(c, label1, "value1")
label2 := inspectFieldMap(c, img.ID, "Config.Labels", "key2")
assert.Assert(c, label2, checker.Equals, "value2")
assert.Equal(c, label2, "value2")
cmd := inspectField(c, img.ID, "Config.Cmd")
assert.Assert(c, cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd))
assert.Equal(c, cmd, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd))
// sanity check, make sure the image is what we think it is
dockerCmd(c, "run", img.ID, "ls", "/test")
@ -615,7 +615,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
assert.Assert(c, containerJSON.HostConfig.NetworkMode, checker.Equals, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode"))
assert.Equal(c, containerJSON.HostConfig.NetworkMode, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode"))
}
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
@ -646,7 +646,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
assert.Equal(c, out, "512")
outCpuset := inspectField(c, containerJSON.ID, "HostConfig.CpusetCpus")
assert.Assert(c, outCpuset, checker.Equals, "0")
assert.Equal(c, outCpuset, "0")
}
func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) {
@ -845,9 +845,9 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *testing.T) {
assert.Equal(c, out, "")
outMemory := inspectField(c, container.ID, "HostConfig.Memory")
assert.Assert(c, outMemory, checker.Equals, "0")
assert.Equal(c, outMemory, "0")
outMemorySwap := inspectField(c, container.ID, "HostConfig.MemorySwap")
assert.Assert(c, outMemorySwap, checker.Equals, "0")
assert.Equal(c, outMemorySwap, "0")
}
func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
@ -888,7 +888,7 @@ func (s *DockerSuite) TestContainerAPIRename(c *testing.T) {
assert.NilError(c, err)
name := inspectField(c, containerID, "Name")
assert.Assert(c, name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container"))
assert.Equal(c, name, "/"+newName, check.Commentf("Failed to rename container"))
}
func (s *DockerSuite) TestContainerAPIKill(c *testing.T) {
@ -903,7 +903,7 @@ func (s *DockerSuite) TestContainerAPIKill(c *testing.T) {
assert.NilError(c, err)
state := inspectField(c, name, "State.Running")
assert.Assert(c, state, checker.Equals, "false", check.Commentf("got wrong State from container %s: %q", name, state))
assert.Equal(c, state, "false", check.Commentf("got wrong State from container %s: %q", name, state))
}
func (s *DockerSuite) TestContainerAPIRestart(c *testing.T) {
@ -1000,7 +1000,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *testing.T) {
case err = <-errC:
assert.NilError(c, err)
case waitres := <-waitresC:
assert.Assert(c, waitres.StatusCode, checker.Equals, int64(0))
assert.Equal(c, waitres.StatusCode, int64(0))
}
}
@ -1156,7 +1156,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
assert.Assert(c, waitRun(id2), checker.IsNil)
links := inspectFieldJSON(c, id2, "HostConfig.Links")
assert.Assert(c, links, checker.Equals, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers"))
assert.Equal(c, links, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers"))
removeOptions := types.ContainerRemoveOptions{
RemoveLinks: true,
@ -1170,7 +1170,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
assert.NilError(c, err)
linksPostRm := inspectFieldJSON(c, id2, "HostConfig.Links")
assert.Assert(c, linksPostRm, checker.Equals, "null", check.Commentf("call to api deleteContainer links should have removed the specified links"))
assert.Equal(c, linksPostRm, "null", check.Commentf("call to api deleteContainer links should have removed the specified links"))
}
func (s *DockerSuite) TestContainerAPIDeleteConflict(c *testing.T) {
@ -1457,7 +1457,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, defaultSHMSize)
assert.Equal(c, containerJSON.HostConfig.ShmSize, defaultSHMSize)
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
@ -1484,7 +1484,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, int64(67108864))
assert.Equal(c, containerJSON.HostConfig.ShmSize, int64(67108864))
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
@ -1515,7 +1515,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, int64(1073741824))
assert.Equal(c, containerJSON.HostConfig.ShmSize, int64(1073741824))
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
shmRegex := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=1048576k`)
@ -1542,7 +1542,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
assert.NilError(c, err)
if versions.LessThan(testEnv.DaemonAPIVersion(), "1.31") {
assert.Assert(c, *containerJSON.HostConfig.MemorySwappiness, checker.Equals, int64(-1))
assert.Equal(c, *containerJSON.HostConfig.MemorySwappiness, int64(-1))
} else {
assert.Assert(c, containerJSON.HostConfig.MemorySwappiness, checker.IsNil)
}

View file

@ -17,7 +17,7 @@ func (s *DockerSwarmSuite) TestAPISwarmListNodes(c *testing.T) {
d3 := s.AddDaemon(c, true, false)
nodes := d1.ListNodes(c)
assert.Assert(c, len(nodes), checker.Equals, 3, check.Commentf("nodes: %#v", nodes))
assert.Equal(c, len(nodes), 3, check.Commentf("nodes: %#v", nodes))
loop0:
for _, n := range nodes {
@ -40,7 +40,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *testing.T) {
})
n := d.GetNode(c, nodes[0].ID)
assert.Assert(c, n.Spec.Availability, checker.Equals, swarm.NodeAvailabilityPause)
assert.Equal(c, n.Spec.Availability, swarm.NodeAvailabilityPause)
}
func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
@ -50,7 +50,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
_ = s.AddDaemon(c, true, false)
nodes := d1.ListNodes(c)
assert.Assert(c, len(nodes), checker.Equals, 3, check.Commentf("nodes: %#v", nodes))
assert.Equal(c, len(nodes), 3, check.Commentf("nodes: %#v", nodes))
// Getting the info so we can take the NodeID
d2Info := d2.SwarmInfo(c)
@ -59,7 +59,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
d1.RemoveNode(c, d2Info.NodeID, true)
nodes = d1.ListNodes(c)
assert.Assert(c, len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
assert.Equal(c, len(nodes), 2, check.Commentf("nodes: %#v", nodes))
// Restart the node that was removed
d2.RestartNode(c)
@ -69,7 +69,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
// Make sure the node didn't rejoin
nodes = d1.ListNodes(c)
assert.Assert(c, len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
assert.Equal(c, len(nodes), 2, check.Commentf("nodes: %#v", nodes))
}
func (s *DockerSwarmSuite) TestAPISwarmNodeDrainPause(c *testing.T) {

View file

@ -157,13 +157,13 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
assert.NilError(c, err)
out, err = bufio.NewReader(stdout).ReadString('\n')
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello")
assert.Equal(c, strings.TrimSpace(out), "hello")
assert.Assert(c, stdin.Close(), checker.IsNil)
// Expect container to still be running after stdin is closed
running := inspectField(c, id, "State.Running")
assert.Assert(c, running, checker.Equals, "true")
assert.Equal(c, running, "true")
}
func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) {

View file

@ -2082,7 +2082,7 @@ CMD ["cat", "/foo"]`),
}).Assert(c, icmd.Success)
res := inspectField(c, name, "Config.Cmd")
assert.Assert(c, strings.TrimSpace(string(res)), checker.Equals, `[cat /foo]`)
assert.Equal(c, strings.TrimSpace(string(res)), `[cat /foo]`)
}
// FIXME(vdemeester) migrate to docker/cli tests (unit or e2e)
@ -2142,9 +2142,9 @@ COPY . /baz`),
result = cli.DockerCmd(c, "run", "--rm", name, "ls", "-A", "/baz")
if hasDockerignore && !ignoreDockerignore {
assert.Assert(c, result.Stdout(), checker.Equals, ".dockerignore\nfoo\n")
assert.Equal(c, result.Stdout(), ".dockerignore\nfoo\n")
} else {
assert.Assert(c, result.Stdout(), checker.Equals, "foo\n")
assert.Equal(c, result.Stdout(), "foo\n")
}
}
@ -4178,7 +4178,7 @@ func (s *DockerSuite) TestBuildTimeArgHistoryExclusions(c *testing.T) {
result.Assert(c, icmd.Expected{Out: fmt.Sprintf("%s=%s", explicitProxyKey, explicitProxyVal)})
cacheID := buildImage(imgName + "-two")
assert.Assert(c, origID, checker.Equals, cacheID)
assert.Equal(c, origID, cacheID)
}
func (s *DockerSuite) TestBuildBuildTimeArgCacheHit(c *testing.T) {
@ -4373,7 +4373,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *testing.T) {
)
res := inspectField(c, imgName, "Config.WorkingDir")
assert.Assert(c, filepath.ToSlash(res), checker.Equals, filepath.ToSlash(wdVal))
assert.Equal(c, filepath.ToSlash(res), filepath.ToSlash(wdVal))
var resArr []string
inspectFieldAndUnmarshall(c, imgName, "Config.Env", &resArr)
@ -4754,7 +4754,7 @@ func (s *DockerSuite) TestBuildMultipleTags(c *testing.T) {
id1 := getIDByName(c, "tag1")
id2 := getIDByName(c, "tag2:v2")
assert.Assert(c, id1, checker.Equals, id2)
assert.Equal(c, id1, id2)
}
// #17290
@ -4949,7 +4949,7 @@ func (s *DockerSuite) TestBuildLabelOneNode(c *testing.T) {
if !ok {
c.Fatal("label `foo` not found in image")
}
assert.Assert(c, v, checker.Equals, "bar")
assert.Equal(c, v, "bar")
}
func (s *DockerSuite) TestBuildLabelCacheCommit(c *testing.T) {
@ -5425,8 +5425,8 @@ func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *testing.T) {
// rebuild with cache-from
result := cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 := getIDByName(c, "build2")
assert.Assert(c, id1, checker.Equals, id2)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 2)
assert.Equal(c, id1, id2)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2)
}
func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
@ -5450,15 +5450,15 @@ func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
// rebuild with cache-from
result := cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 := getIDByName(c, "build2")
assert.Assert(c, id1, checker.Equals, id2)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 3)
assert.Equal(c, id1, id2)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 3)
cli.DockerCmd(c, "rmi", "build2")
// no cache match with unknown source
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=nosuchtag"), build.WithExternalBuildContext(ctx))
id2 = getIDByName(c, "build2")
assert.Assert(c, id1 != id2)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 0)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 0)
cli.DockerCmd(c, "rmi", "build2")
// clear parent images
@ -5472,23 +5472,23 @@ func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
cli.DockerCmd(c, "rmi", "build1")
cli.DockerCmd(c, "load", "-i", tempFile)
parentID := cli.DockerCmd(c, "inspect", "-f", "{{.Parent}}", "build1").Combined()
assert.Assert(c, strings.TrimSpace(parentID), checker.Equals, "")
assert.Equal(c, strings.TrimSpace(parentID), "")
// cache still applies without parents
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 = getIDByName(c, "build2")
assert.Assert(c, id1, checker.Equals, id2)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 3)
assert.Equal(c, id1, id2)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 3)
history1 := cli.DockerCmd(c, "history", "-q", "build2").Combined()
// Retry, no new intermediate images
result = cli.BuildCmd(c, "build3", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id3 := getIDByName(c, "build3")
assert.Assert(c, id1, checker.Equals, id3)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 3)
assert.Equal(c, id1, id3)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 3)
history2 := cli.DockerCmd(c, "history", "-q", "build3").Combined()
assert.Assert(c, history1, checker.Equals, history2)
assert.Equal(c, history1, history2)
cli.DockerCmd(c, "rmi", "build2")
cli.DockerCmd(c, "rmi", "build3")
cli.DockerCmd(c, "rmi", "build1")
@ -5506,7 +5506,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 = getIDByName(c, "build2")
assert.Assert(c, id1 != id2)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 2)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2)
layers1Str := cli.DockerCmd(c, "inspect", "-f", "{{json .RootFS.Layers}}", "build1").Combined()
layers2Str := cli.DockerCmd(c, "inspect", "-f", "{{json .RootFS.Layers}}", "build2").Combined()
@ -5516,9 +5516,9 @@ func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(layers1Str), &layers1), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(layers2Str), &layers2), checker.IsNil)
assert.Assert(c, len(layers1), checker.Equals, len(layers2))
assert.Equal(c, len(layers1), len(layers2))
for i := 0; i < len(layers1)-1; i++ {
assert.Assert(c, layers1[i], checker.Equals, layers2[i])
assert.Equal(c, layers1[i], layers2[i])
}
assert.Assert(c, layers1[len(layers1)-1] != layers2[len(layers1)-1])
}
@ -5540,11 +5540,11 @@ func (s *DockerSuite) TestBuildMultiStageCache(c *testing.T) {
result := cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx))
// second part of dockerfile was a repeat of first so should be cached
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 1)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 1)
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
// now both parts of dockerfile should be cached
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 2)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2)
}
func (s *DockerSuite) TestBuildNetNone(c *testing.T) {
@ -5572,7 +5572,7 @@ func (s *DockerSuite) TestBuildNetContainer(c *testing.T) {
`))
host, _ := dockerCmd(c, "run", "testbuildnetcontainer", "cat", "/otherhost")
assert.Assert(c, strings.TrimSpace(host), checker.Equals, "foobar")
assert.Equal(c, strings.TrimSpace(host), "foobar")
}
func (s *DockerSuite) TestBuildWithExtraHost(c *testing.T) {
@ -5681,22 +5681,22 @@ func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) {
result := cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
// all commands should be cached
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 7)
assert.Assert(c, getIDByName(c, "build1"), checker.Equals, getIDByName(c, "build2"))
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 7)
assert.Equal(c, getIDByName(c, "build1"), getIDByName(c, "build2"))
err := ioutil.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(fmt.Sprintf(dockerfile, "COPY baz/aa foo")), 0644)
assert.NilError(c, err)
// changing file in parent block should not affect last block
result = cli.BuildCmd(c, "build3", build.WithExternalBuildContext(ctx))
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 5)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("pqr"), 0644)
assert.NilError(c, err)
// changing file in parent block should affect both first and last block
result = cli.BuildCmd(c, "build4", build.WithExternalBuildContext(ctx))
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 5)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
cli.DockerCmd(c, "run", "build4", "cat", "bay").Assert(c, icmd.Expected{Out: "pqr"})
cli.DockerCmd(c, "run", "build4", "cat", "baz").Assert(c, icmd.Expected{Out: "pqr"})
@ -5777,9 +5777,9 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuilds(c *testing.T) {
cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "build2", "cat", "bar").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "abc")
assert.Equal(c, strings.TrimSpace(out), "abc")
out = cli.DockerCmd(c, "run", "build2", "cat", "foo").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "def")
assert.Equal(c, strings.TrimSpace(out), "def")
}
func (s *DockerSuite) TestBuildMultiStageImplicitFrom(c *testing.T) {
@ -5893,9 +5893,9 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *testing.T) {
cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\bar").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "abc")
assert.Equal(c, strings.TrimSpace(out), "abc")
out = cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\foo").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "def")
assert.Equal(c, strings.TrimSpace(out), "def")
}
func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) {
@ -5969,7 +5969,7 @@ func (s *DockerSuite) TestBuildMultiStageResetScratch(c *testing.T) {
cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx))
res := cli.InspectCmd(c, "build1", cli.Format(".Config.WorkingDir")).Combined()
assert.Assert(c, strings.TrimSpace(res), checker.Equals, "")
assert.Equal(c, strings.TrimSpace(res), "")
}
func (s *DockerSuite) TestBuildIntermediateTarget(c *testing.T) {
@ -5990,14 +5990,14 @@ func (s *DockerSuite) TestBuildIntermediateTarget(c *testing.T) {
cli.WithFlags("--target", "build-env"))
res := cli.InspectCmd(c, "build1", cli.Format("json .Config.Cmd")).Combined()
assert.Assert(c, strings.TrimSpace(res), checker.Equals, `["/dev"]`)
assert.Equal(c, strings.TrimSpace(res), `["/dev"]`)
// Stage name is case-insensitive by design
cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx),
cli.WithFlags("--target", "BUIld-EnV"))
res = cli.InspectCmd(c, "build1", cli.Format("json .Config.Cmd")).Combined()
assert.Assert(c, strings.TrimSpace(res), checker.Equals, `["/dev"]`)
assert.Equal(c, strings.TrimSpace(res), `["/dev"]`)
result := cli.Docker(cli.Build("build1"), build.WithExternalBuildContext(ctx),
cli.WithFlags("--target", "nosuchtarget"))
@ -6100,7 +6100,7 @@ func (s *DockerSuite) TestBuildWorkdirCmd(c *testing.T) {
buildImageSuccessfully(c, name, build.WithDockerfile(dockerFile))
result := buildImage(name, build.WithDockerfile(dockerFile))
result.Assert(c, icmd.Success)
assert.Assert(c, strings.Count(result.Combined(), "Using cache"), checker.Equals, 1)
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 1)
}
// FIXME(vdemeester) should be a unit test
@ -6200,7 +6200,7 @@ ENV BAR BAZ`),
assert.NilError(c, err)
d, err := digest.Parse(string(id))
assert.NilError(c, err)
assert.Assert(c, d.String(), checker.Equals, getIDByName(c, name))
assert.Equal(c, d.String(), getIDByName(c, name))
}
// FIXME(vdemeester) should migrate to docker/cli tests
@ -6223,5 +6223,5 @@ func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *testing.T) {
})
_, err = os.Stat(tmpIidFile)
assert.ErrorContains(c, err, "")
assert.Assert(c, os.IsNotExist(err), checker.Equals, true)
assert.Equal(c, os.IsNotExist(err), true)
}

View file

@ -58,14 +58,14 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
err := json.Unmarshal([]byte(cfg), &c1)
assert.Assert(c, err, checker.IsNil, check.Commentf(cfg))
assert.Assert(c, c1.Memory, checker.Equals, int64(64*1024*1024), check.Commentf("resource constraints not set properly for Memory"))
assert.Assert(c, c1.MemorySwap, checker.Equals, int64(-1), check.Commentf("resource constraints not set properly for MemorySwap"))
assert.Assert(c, c1.CpusetCpus, checker.Equals, "0", check.Commentf("resource constraints not set properly for CpusetCpus"))
assert.Assert(c, c1.CpusetMems, checker.Equals, "0", check.Commentf("resource constraints not set properly for CpusetMems"))
assert.Assert(c, c1.CPUShares, checker.Equals, int64(100), check.Commentf("resource constraints not set properly for CPUShares"))
assert.Assert(c, c1.CPUQuota, checker.Equals, int64(8000), check.Commentf("resource constraints not set properly for CPUQuota"))
assert.Assert(c, c1.Ulimits[0].Name, checker.Equals, "nofile", check.Commentf("resource constraints not set properly for Ulimits"))
assert.Assert(c, c1.Ulimits[0].Hard, checker.Equals, int64(42), check.Commentf("resource constraints not set properly for Ulimits"))
assert.Equal(c, c1.Memory, int64(64*1024*1024), check.Commentf("resource constraints not set properly for Memory"))
assert.Equal(c, c1.MemorySwap, int64(-1), check.Commentf("resource constraints not set properly for MemorySwap"))
assert.Equal(c, c1.CpusetCpus, "0", check.Commentf("resource constraints not set properly for CpusetCpus"))
assert.Equal(c, c1.CpusetMems, "0", check.Commentf("resource constraints not set properly for CpusetMems"))
assert.Equal(c, c1.CPUShares, int64(100), check.Commentf("resource constraints not set properly for CPUShares"))
assert.Equal(c, c1.CPUQuota, int64(8000), check.Commentf("resource constraints not set properly for CPUQuota"))
assert.Equal(c, c1.Ulimits[0].Name, "nofile", check.Commentf("resource constraints not set properly for Ulimits"))
assert.Equal(c, c1.Ulimits[0].Hard, int64(42), check.Commentf("resource constraints not set properly for Ulimits"))
// Make sure constraints aren't saved to image
cli.DockerCmd(c, "run", "--name=test", name)

View file

@ -73,7 +73,7 @@ func testPullByTagDisplaysDigest(c *testing.T) {
pullDigest := matches[1]
// make sure the pushed and pull digests match
assert.Assert(c, pushDigest.String(), checker.Equals, pullDigest)
assert.Equal(c, pushDigest.String(), pullDigest)
}
func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(c *testing.T) {
@ -99,7 +99,7 @@ func testPullByDigest(c *testing.T) {
pullDigest := matches[1]
// make sure the pushed and pull digests match
assert.Assert(c, pushDigest.String(), checker.Equals, pullDigest)
assert.Equal(c, pushDigest.String(), pullDigest)
}
func (s *DockerRegistrySuite) TestPullByDigest(c *testing.T) {
@ -152,7 +152,7 @@ func (s *DockerRegistrySuite) TestRunByDigest(c *testing.T) {
foundRegex := regexp.MustCompile("found=([^\n]+)")
matches := foundRegex.FindStringSubmatch(out)
assert.Assert(c, matches, checker.HasLen, 2, check.Commentf("unable to parse digest from pull output: %s", out))
assert.Assert(c, matches[1], checker.Equals, "1", check.Commentf("Expected %q, got %q", "1", matches[1]))
assert.Equal(c, matches[1], "1", check.Commentf("Expected %q, got %q", "1", matches[1]))
res := inspectField(c, containerName, "Config.Image")
assert.Equal(c, res, imageReference)

View file

@ -61,7 +61,7 @@ func (s *DockerSuite) TestCommitNewFile(c *testing.T) {
out, _ := dockerCmd(c, "run", imageID, "cat", "/foo")
actual := strings.TrimSpace(out)
assert.Assert(c, actual, checker.Equals, "koye")
assert.Equal(c, actual, "koye")
}
func (s *DockerSuite) TestCommitHardlink(c *testing.T) {
@ -161,7 +161,7 @@ func (s *DockerSuite) TestCommitChangeLabels(c *testing.T) {
"test", "test-commit")
imageID = strings.TrimSpace(imageID)
assert.Assert(c, inspectField(c, imageID, "Config.Labels"), checker.Equals, "map[some:label2]")
assert.Equal(c, inspectField(c, imageID, "Config.Labels"), "map[some:label2]")
// check that container labels didn't change
assert.Assert(c, inspectField(c, "test", "Config.Labels"), checker.Equals, "map[some:label]")
assert.Equal(c, inspectField(c, "test", "Config.Labels"), "map[some:label]")
}

View file

@ -41,7 +41,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) {
assert.Equal(c, len(containers), 1)
cont := containers[0]
assert.Assert(c, string(cont.Path), checker.Equals, "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path))
assert.Equal(c, string(cont.Path), "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path))
b := false
expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
@ -68,7 +68,7 @@ func (s *DockerSuite) TestCreateGrowRootfs(c *testing.T) {
cleanedContainerID := strings.TrimSpace(out)
inspectOut := inspectField(c, cleanedContainerID, "HostConfig.StorageOpt")
assert.Assert(c, inspectOut, checker.Equals, "map[size:120G]")
assert.Equal(c, inspectOut, "map[size:120G]")
}
// Make sure we cannot shrink the container's rootfs at creation time.
@ -127,7 +127,7 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) {
for k, v := range cont.HostConfig.PortBindings {
assert.Assert(c, v, checker.HasLen, 1, check.Commentf("Expected 1 ports binding, for the port %s but found %s", k, v))
assert.Assert(c, k.Port(), checker.Equals, v[0].HostPort, check.Commentf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
assert.Equal(c, k.Port(), v[0].HostPort, check.Commentf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
}
@ -156,7 +156,7 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) {
for k, v := range cont.HostConfig.PortBindings {
assert.Assert(c, v, checker.HasLen, 1)
assert.Assert(c, k.Port(), checker.Equals, v[0].HostPort, check.Commentf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
assert.Equal(c, k.Port(), v[0].HostPort, check.Commentf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
}
}
@ -364,7 +364,7 @@ exec "$@"`,
id := strings.TrimSpace(out)
assert.Assert(c, id != "")
out = cli.DockerCmd(c, "start", "-a", id).Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "foo")
assert.Equal(c, strings.TrimSpace(out), "foo")
}
// #22471

View file

@ -136,7 +136,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *testing.T) {
} else {
format = "%scontainer %q is running"
}
assert.Assert(c, strings.Contains(out, name), checker.Equals, shouldRun, check.Commentf(format, prefix, name))
assert.Equal(c, strings.Contains(out, name), shouldRun, check.Commentf(format, prefix, name))
}
}
@ -245,7 +245,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T)
basesizeAfterRestart := getBaseDeviceSize(c, s.d)
newBasesize, err := convertBasesize(newBasesizeBytes)
assert.Assert(c, err, checker.IsNil, check.Commentf("Error in converting base device size: %v", err))
assert.Assert(c, newBasesize, checker.Equals, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set"))
assert.Equal(c, newBasesize, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set"))
s.d.Stop(c)
}
@ -439,7 +439,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.IPv6Gateway}}", "ipv6test")
assert.NilError(c, err, out)
assert.Assert(c, strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:2::100", check.Commentf("Container should have a global IPv6 gateway"))
assert.Equal(c, strings.Trim(out, " \r\n'"), "2001:db8:2::100", check.Commentf("Container should have a global IPv6 gateway"))
}
// TestDaemonIPv6FixedCIDRAndMac checks that when the daemon is started with ipv6 fixed CIDR
@ -458,7 +458,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *testing.T) {
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
assert.NilError(c, err, out)
assert.Assert(c, strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:1::aabb:ccdd:eeff")
assert.Equal(c, strings.Trim(out, " \r\n'"), "2001:db8:1::aabb:ccdd:eeff")
}
// TestDaemonIPv6HostMode checks that when the running a container with
@ -679,7 +679,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *testing.T) {
containerIP := d.FindContainerIP(c, "test")
ip = net.ParseIP(containerIP)
assert.Assert(c, bridgeIPNet.Contains(ip), checker.Equals, true, check.Commentf("Container IP-Address must be in the same subnet range : %s", containerIP))
assert.Equal(c, bridgeIPNet.Contains(ip), true, check.Commentf("Container IP-Address must be in the same subnet range : %s", containerIP))
deleteInterface(c, defaultNetworkBridge)
}
@ -783,7 +783,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *testing.T) {
expectedMessage := fmt.Sprintf("default via %s dev", bridgeIP)
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
assert.NilError(c, err, out)
assert.Assert(c, strings.Contains(out, expectedMessage), checker.Equals, true, check.Commentf("Implicit default gateway should be bridge IP %s, but default route was '%s'", bridgeIP, strings.TrimSpace(out)))
assert.Equal(c, strings.Contains(out, expectedMessage), true, check.Commentf("Implicit default gateway should be bridge IP %s, but default route was '%s'", bridgeIP, strings.TrimSpace(out)))
deleteInterface(c, defaultNetworkBridge)
}
@ -803,7 +803,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *testing.T) {
expectedMessage := fmt.Sprintf("default via %s dev", gatewayIP)
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
assert.NilError(c, err, out)
assert.Assert(c, strings.Contains(out, expectedMessage), checker.Equals, true, check.Commentf("Explicit default gateway should be %s, but default route was '%s'", gatewayIP, strings.TrimSpace(out)))
assert.Equal(c, strings.Contains(out, expectedMessage), true, check.Commentf("Explicit default gateway should be %s, but default route was '%s'", gatewayIP, strings.TrimSpace(out)))
deleteInterface(c, defaultNetworkBridge)
}
@ -845,7 +845,7 @@ func (s *DockerDaemonSuite) TestDaemonIP(c *testing.T) {
out, err := d.Cmd("run", "-d", "-p", "8000:8000", "busybox", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("Running a container must fail with an invalid --ip option"))
assert.Assert(c, strings.Contains(out, "Error starting userland proxy"), checker.Equals, true)
assert.Equal(c, strings.Contains(out, "Error starting userland proxy"), true)
ifName := "dummy"
createInterface(c, "dummy", ifName, ipStr)
@ -858,7 +858,7 @@ func (s *DockerDaemonSuite) TestDaemonIP(c *testing.T) {
result.Assert(c, icmd.Success)
regex := fmt.Sprintf("DNAT.*%s.*dpt:8000", ip.String())
matched, _ := regexp.MatchString(regex, result.Combined())
assert.Assert(c, matched, checker.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
assert.Equal(c, matched, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
}
func (s *DockerDaemonSuite) TestDaemonICCPing(c *testing.T) {
@ -878,7 +878,7 @@ func (s *DockerDaemonSuite) TestDaemonICCPing(c *testing.T) {
result.Assert(c, icmd.Success)
regex := fmt.Sprintf("DROP.*all.*%s.*%s", bridgeName, bridgeName)
matched, _ := regexp.MatchString(regex, result.Combined())
assert.Assert(c, matched, checker.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
assert.Equal(c, matched, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
// Pinging another container must fail with --icc=false
pingContainers(c, d, true)
@ -911,7 +911,7 @@ func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *testing.T) {
result.Assert(c, icmd.Success)
regex := fmt.Sprintf("DROP.*all.*%s.*%s", bridgeName, bridgeName)
matched, _ := regexp.MatchString(regex, result.Combined())
assert.Assert(c, matched, checker.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
assert.Equal(c, matched, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
out, err := d.Cmd("run", "-d", "--expose", "4567", "--name", "icc1", "busybox", "nc", "-l", "-p", "4567")
assert.NilError(c, err, out)
@ -1152,7 +1152,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *te
)
comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
assert.Assert(c, result.Error, checker.IsNil, comment)
assert.Assert(c, result.ExitCode, checker.Equals, 0, comment)
assert.Equal(c, result.ExitCode, 0, comment)
assert.Assert(c, result.Combined(), checker.Contains, "foo", comment)
}
@ -1569,7 +1569,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlway
out, err = s.d.Cmd("ps", "-q")
assert.NilError(c, err, out)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, id[:12])
assert.Equal(c, strings.TrimSpace(out), id[:12])
}
func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *testing.T) {
@ -1889,7 +1889,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *testing.T) {
assert.NilError(c, err, out)
out, err = s.d.Cmd("start", "-a", "test2")
assert.NilError(c, err, out)
assert.Assert(c, strings.Contains(out, "1 packets transmitted, 1 packets received"), checker.Equals, true, check.Commentf("%s", out))
assert.Equal(c, strings.Contains(out, "1 packets transmitted, 1 packets received"), true, check.Commentf("%s", out))
}
func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *testing.T) {
@ -2033,7 +2033,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) {
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", mountOut))
comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
assert.Assert(c, strings.Contains(string(mountOut), id), checker.Equals, false, comment)
assert.Equal(c, strings.Contains(string(mountOut), id), false, comment)
}
// TestDaemonRestartWithUnpausedRunningContainer requires live restore of running containers.
@ -2370,7 +2370,7 @@ func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *testing.T)
)
comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
assert.Assert(c, result.Error, checker.IsNil, comment)
assert.Assert(c, result.ExitCode, checker.Equals, 0, comment)
assert.Equal(c, result.ExitCode, 0, comment)
}
// Test case for #21976
@ -2738,7 +2738,7 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
out2, err := s.d.Cmd("exec", "-u", "test", "top", "id")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out2))
assert.Assert(c, out2, checker.Equals, out1, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2))
assert.Equal(c, out2, out1, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2))
out, err = s.d.Cmd("stop", "top")
assert.NilError(c, err, "Output: %s", out)
@ -2848,7 +2848,7 @@ func (s *DockerDaemonSuite) TestShmSize(c *testing.T) {
assert.Assert(c, pattern.MatchString(out), checker.True)
out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.ShmSize}}", name)
assert.NilError(c, err, "Output: %s", out)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%v", size))
assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%v", size))
}
func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
@ -2872,7 +2872,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
assert.Assert(c, pattern.MatchString(out), checker.True)
out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.ShmSize}}", name)
assert.NilError(c, err, "Output: %s", out)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%v", size))
assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%v", size))
size = 67108864 * 3
configData = []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
@ -2888,7 +2888,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
assert.Assert(c, pattern.MatchString(out), checker.True)
out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.ShmSize}}", name)
assert.NilError(c, err, "Output: %s", out)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%v", size))
assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%v", size))
}
func testDaemonStartIpcMode(c *testing.T, from, mode string, valid bool) {

View file

@ -310,11 +310,11 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *testing.T)
assert.ErrorContains(c, err, "")
assert.Assert(c, os.IsNotExist(err), checker.True, check.Commentf("Expected volume path in host to not exist: %s, %v\n", p, err))
assert.Assert(c, s.ec.activations, checker.Equals, 1)
assert.Assert(c, s.ec.creations, checker.Equals, 1)
assert.Assert(c, s.ec.removals, checker.Equals, 1)
assert.Assert(c, s.ec.mounts, checker.Equals, 1)
assert.Assert(c, s.ec.unmounts, checker.Equals, 1)
assert.Equal(c, s.ec.activations, 1)
assert.Equal(c, s.ec.creations, 1)
assert.Equal(c, s.ec.removals, 1)
assert.Equal(c, s.ec.mounts, 1)
assert.Equal(c, s.ec.unmounts, 1)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *testing.T) {
@ -324,11 +324,11 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *testing.T
assert.NilError(c, err, out)
assert.Assert(c, out, checker.Contains, s.Server.URL)
assert.Assert(c, s.ec.activations, checker.Equals, 1)
assert.Assert(c, s.ec.creations, checker.Equals, 1)
assert.Assert(c, s.ec.removals, checker.Equals, 1)
assert.Assert(c, s.ec.mounts, checker.Equals, 1)
assert.Assert(c, s.ec.unmounts, checker.Equals, 1)
assert.Equal(c, s.ec.activations, 1)
assert.Equal(c, s.ec.creations, 1)
assert.Equal(c, s.ec.removals, 1)
assert.Equal(c, s.ec.mounts, 1)
assert.Equal(c, s.ec.unmounts, 1)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *testing.T) {
@ -343,11 +343,11 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *testi
out, err = s.d.Cmd("rm", "-fv", "vol-test1")
assert.NilError(c, err, out)
assert.Assert(c, s.ec.activations, checker.Equals, 1)
assert.Assert(c, s.ec.creations, checker.Equals, 1)
assert.Assert(c, s.ec.removals, checker.Equals, 1)
assert.Assert(c, s.ec.mounts, checker.Equals, 2)
assert.Assert(c, s.ec.unmounts, checker.Equals, 2)
assert.Equal(c, s.ec.activations, 1)
assert.Equal(c, s.ec.creations, 1)
assert.Equal(c, s.ec.removals, 1)
assert.Equal(c, s.ec.mounts, 2)
assert.Equal(c, s.ec.unmounts, 2)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *testing.T) {
@ -359,11 +359,11 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *t
out, err = s.d.Cmd("rm", "-fv", "vol-test1")
assert.NilError(c, err, out)
assert.Assert(c, s.ec.activations, checker.Equals, 1)
assert.Assert(c, s.ec.creations, checker.Equals, 1)
assert.Assert(c, s.ec.removals, checker.Equals, 1)
assert.Assert(c, s.ec.mounts, checker.Equals, 1)
assert.Assert(c, s.ec.unmounts, checker.Equals, 1)
assert.Equal(c, s.ec.activations, 1)
assert.Equal(c, s.ec.creations, 1)
assert.Equal(c, s.ec.removals, 1)
assert.Equal(c, s.ec.mounts, 1)
assert.Equal(c, s.ec.unmounts, 1)
}
func hostVolumePath(name string) string {
@ -437,11 +437,11 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyE
_, err := s.d.Cmd("volume", "rm", "external-volume-test")
assert.NilError(c, err)
assert.Assert(c, p.ec.activations, checker.Equals, 1)
assert.Assert(c, p.ec.creations, checker.Equals, 1)
assert.Assert(c, p.ec.removals, checker.Equals, 1)
assert.Assert(c, p.ec.mounts, checker.Equals, 1)
assert.Assert(c, p.ec.unmounts, checker.Equals, 1)
assert.Equal(c, p.ec.activations, 1)
assert.Equal(c, p.ec.creations, 1)
assert.Equal(c, p.ec.removals, 1)
assert.Equal(c, p.ec.mounts, 1)
assert.Equal(c, p.ec.unmounts, 1)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *testing.T) {
@ -454,30 +454,30 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c
}
out := inspectFieldJSON(c, "testing", "Mounts")
assert.Assert(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts), checker.IsNil)
assert.Assert(c, len(mounts), checker.Equals, 1, check.Commentf("%s", out))
assert.Assert(c, mounts[0].Name, checker.Equals, "foo")
assert.Assert(c, mounts[0].Driver, checker.Equals, volumePluginName)
assert.Equal(c, len(mounts), 1, check.Commentf("%s", out))
assert.Equal(c, mounts[0].Name, "foo")
assert.Equal(c, mounts[0].Driver, volumePluginName)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *testing.T) {
dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc3")
out, _ := dockerCmd(c, "volume", "ls")
ls := strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(ls), checker.Equals, 2, check.Commentf("\n%s", out))
assert.Equal(c, len(ls), 2, check.Commentf("\n%s", out))
vol := strings.Fields(ls[len(ls)-1])
assert.Assert(c, len(vol), checker.Equals, 2, check.Commentf("%v", vol))
assert.Assert(c, vol[0], checker.Equals, volumePluginName)
assert.Assert(c, vol[1], checker.Equals, "abc3")
assert.Equal(c, len(vol), 2, check.Commentf("%v", vol))
assert.Equal(c, vol[0], volumePluginName)
assert.Equal(c, vol[1], "abc3")
assert.Assert(c, s.ec.lists, checker.Equals, 1)
assert.Equal(c, s.ec.lists, 1)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) {
out, _, err := dockerCmdWithError("volume", "inspect", "dummy")
assert.ErrorContains(c, err, "", out)
assert.Assert(c, out, checker.Contains, "No such volume")
assert.Assert(c, s.ec.gets, checker.Equals, 1)
assert.Equal(c, s.ec.gets, 1)
dockerCmd(c, "volume", "create", "test", "-d", volumePluginName)
out, _ = dockerCmd(c, "volume", "inspect", "test")
@ -490,7 +490,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &st), checker.IsNil)
assert.Assert(c, st, checker.HasLen, 1)
assert.Assert(c, st[0].Status, checker.HasLen, 1, check.Commentf("%v", st[0]))
assert.Assert(c, st[0].Status["Hello"], checker.Equals, "world", check.Commentf("%v", st[0].Status))
assert.Equal(c, st[0].Status["Hello"], "world", check.Commentf("%v", st[0].Status))
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c *testing.T) {
@ -501,7 +501,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c
var mounts []types.MountPoint
inspectFieldAndUnmarshall(c, "test", "Mounts", &mounts)
assert.Assert(c, mounts, checker.HasLen, 1)
assert.Assert(c, mounts[0].Driver, checker.Equals, volumePluginName)
assert.Equal(c, mounts[0].Driver, volumePluginName)
}
// Ensures that the daemon handles when the plugin responds to a `Get` request with a null volume and a null error.
@ -523,15 +523,15 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *
// available because the volume is not even mounted. Consider removing this test.
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *testing.T) {
s.d.Start(c)
assert.Assert(c, s.ec.paths, checker.Equals, 0)
assert.Equal(c, s.ec.paths, 0)
out, err := s.d.Cmd("volume", "create", "test", "--driver=test-external-volume-driver")
assert.NilError(c, err, out)
assert.Assert(c, s.ec.paths, checker.Equals, 0)
assert.Equal(c, s.ec.paths, 0)
out, err = s.d.Cmd("volume", "ls")
assert.NilError(c, err, out)
assert.Assert(c, s.ec.paths, checker.Equals, 0)
assert.Equal(c, s.ec.paths, 0)
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *testing.T) {
@ -545,12 +545,12 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *testing.T
// Check that VolumeDriver.Capabilities gets called, and only called once
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *testing.T) {
s.d.Start(c)
assert.Assert(c, s.ec.caps, checker.Equals, 0)
assert.Equal(c, s.ec.caps, 0)
for i := 0; i < 3; i++ {
out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, fmt.Sprintf("test%d", i))
assert.NilError(c, err, out)
assert.Assert(c, s.ec.caps, checker.Equals, 1)
assert.Equal(c, s.ec.caps, 1)
out, err = s.d.Cmd("volume", "inspect", "--format={{.Scope}}", fmt.Sprintf("test%d", i))
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), volume.GlobalScope)
@ -584,10 +584,10 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *t
err = json.Unmarshal([]byte(out), &vs)
assert.NilError(c, err)
assert.Assert(c, vs, checker.HasLen, 1)
assert.Assert(c, vs[0].Driver, checker.Equals, driverName)
assert.Equal(c, vs[0].Driver, driverName)
assert.Assert(c, vs[0].Options, checker.NotNil)
assert.Assert(c, vs[0].Options["foo"], checker.Equals, "bar")
assert.Assert(c, vs[0].Driver, checker.Equals, driverName)
assert.Equal(c, vs[0].Options["foo"], "bar")
assert.Equal(c, vs[0].Driver, driverName)
// simulate out of band volume deletion on plugin level
delete(p.vols, "test")
@ -603,7 +603,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *t
assert.NilError(c, err)
assert.Assert(c, vs, checker.HasLen, 1)
assert.Assert(c, vs[0].Options, checker.HasLen, 0)
assert.Assert(c, vs[0].Driver, checker.Equals, "local")
assert.Equal(c, vs[0].Driver, "local")
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *testing.T) {
@ -611,9 +611,9 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--opt=invalidOption=1", "--name=testumount")
out, _ := s.d.Cmd("run", "-v", "testumount:/foo", "busybox", "true")
assert.Assert(c, s.ec.unmounts, checker.Equals, 0, check.Commentf("%s", out))
assert.Equal(c, s.ec.unmounts, 0, check.Commentf("%s", out))
out, _ = s.d.Cmd("run", "-w", "/foo", "-v", "testumount:/foo", "busybox", "true")
assert.Assert(c, s.ec.unmounts, checker.Equals, 0, check.Commentf("%s", out))
assert.Equal(c, s.ec.unmounts, 0, check.Commentf("%s", out))
}
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *testing.T) {
@ -621,12 +621,12 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *testi
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name=test")
out, _ := s.d.Cmd("run", "-d", "--name=test", "-v", "test:/foo", "busybox", "/bin/sh", "-c", "touch /test && top")
assert.Assert(c, s.ec.mounts, checker.Equals, 1, check.Commentf("%s", out))
assert.Equal(c, s.ec.mounts, 1, check.Commentf("%s", out))
out, _ = s.d.Cmd("cp", "test:/test", "/tmp/test")
assert.Assert(c, s.ec.mounts, checker.Equals, 2, check.Commentf("%s", out))
assert.Assert(c, s.ec.unmounts, checker.Equals, 1, check.Commentf("%s", out))
assert.Equal(c, s.ec.mounts, 2, check.Commentf("%s", out))
assert.Equal(c, s.ec.unmounts, 1, check.Commentf("%s", out))
out, _ = s.d.Cmd("kill", "test")
assert.Assert(c, s.ec.unmounts, checker.Equals, 2, check.Commentf("%s", out))
assert.Equal(c, s.ec.unmounts, 2, check.Commentf("%s", out))
}

View file

@ -20,7 +20,7 @@ func waitForHealthStatus(c *testing.T, name string, prev string, expected string
if out == expected {
return
}
assert.Assert(c, out, checker.Equals, prev)
assert.Equal(c, out, prev)
if out != prev {
return
}
@ -32,7 +32,7 @@ func getHealth(c *testing.T, name string) *types.Health {
out, _ := dockerCmd(c, "inspect", "--format={{json .State.Health}}", name)
var health types.Health
err := json.Unmarshal([]byte(out), &health)
assert.Assert(c, err, checker.Equals, nil)
assert.Equal(c, err, nil)
return &health
}
@ -54,12 +54,12 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
cid, _ := dockerCmd(c, "create", "--name", name, imageName)
out, _ := dockerCmd(c, "ps", "-a", "--format={{.ID}} {{.Status}}")
out = RemoveOutputForExistingElements(out, existingContainers)
assert.Assert(c, out, checker.Equals, cid[:12]+" Created\n")
assert.Equal(c, out, cid[:12]+" Created\n")
// Inspect the options
out, _ = dockerCmd(c, "inspect",
"--format=timeout={{.Config.Healthcheck.Timeout}} interval={{.Config.Healthcheck.Interval}} retries={{.Config.Healthcheck.Retries}} test={{.Config.Healthcheck.Test}}", name)
assert.Assert(c, out, checker.Equals, "timeout=30s interval=1s retries=0 test=[CMD-SHELL cat /status]\n")
assert.Equal(c, out, "timeout=30s interval=1s retries=0 test=[CMD-SHELL cat /status]\n")
// Start
dockerCmd(c, "start", name)
@ -71,7 +71,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
// Inspect the status
out, _ = dockerCmd(c, "inspect", "--format={{.State.Health.Status}}", name)
assert.Assert(c, out, checker.Equals, "unhealthy\n")
assert.Equal(c, out, "unhealthy\n")
// Make it healthy again
dockerCmd(c, "exec", name, "touch", "/status")
@ -83,7 +83,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
// Disable the check from the CLI
dockerCmd(c, "create", "--name=noh", "--no-healthcheck", imageName)
out, _ = dockerCmd(c, "inspect", "--format={{.Config.Healthcheck.Test}}", "noh")
assert.Assert(c, out, checker.Equals, "[NONE]\n")
assert.Equal(c, out, "[NONE]\n")
dockerCmd(c, "rm", "noh")
// Disable the check with a new build
@ -91,7 +91,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
HEALTHCHECK NONE`))
out, _ = dockerCmd(c, "inspect", "--format={{.Config.Healthcheck.Test}}", "no_healthcheck")
assert.Assert(c, out, checker.Equals, "[NONE]\n")
assert.Equal(c, out, "[NONE]\n")
// Enable the checks from the CLI
_, _ = dockerCmd(c, "run", "-d", "--name=fatal_healthcheck",
@ -101,11 +101,11 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
"no_healthcheck")
waitForHealthStatus(c, "fatal_healthcheck", "starting", "healthy")
health := getHealth(c, "fatal_healthcheck")
assert.Assert(c, health.Status, checker.Equals, "healthy")
assert.Assert(c, health.FailingStreak, checker.Equals, 0)
assert.Equal(c, health.Status, "healthy")
assert.Equal(c, health.FailingStreak, 0)
last := health.Log[len(health.Log)-1]
assert.Assert(c, last.ExitCode, checker.Equals, 0)
assert.Assert(c, last.Output, checker.Equals, "OK\n")
assert.Equal(c, last.ExitCode, 0)
assert.Equal(c, last.Output, "OK\n")
// Fail the check
dockerCmd(c, "exec", "fatal_healthcheck", "rm", "/status")
@ -114,7 +114,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
failsStr, _ := dockerCmd(c, "inspect", "--format={{.State.Health.FailingStreak}}", "fatal_healthcheck")
fails, err := strconv.Atoi(strings.TrimSpace(failsStr))
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, fails >= 3, checker.Equals, true)
assert.Equal(c, fails >= 3, true)
dockerCmd(c, "rm", "-f", "fatal_healthcheck")
// Check timeout
@ -125,9 +125,9 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
waitForHealthStatus(c, "test", "starting", "unhealthy")
health = getHealth(c, "test")
last = health.Log[len(health.Log)-1]
assert.Assert(c, health.Status, checker.Equals, "unhealthy")
assert.Assert(c, last.ExitCode, checker.Equals, -1)
assert.Assert(c, last.Output, checker.Equals, "Health check exceeded timeout (1s)")
assert.Equal(c, health.Status, "unhealthy")
assert.Equal(c, last.ExitCode, -1)
assert.Equal(c, last.Output, "Health check exceeded timeout (1s)")
dockerCmd(c, "rm", "-f", "test")
// Check JSON-format
@ -139,7 +139,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
CMD ["cat", "/my status"]`))
out, _ = dockerCmd(c, "inspect",
"--format={{.Config.Healthcheck.Test}}", imageName)
assert.Assert(c, out, checker.Equals, "[CMD cat /my status]\n")
assert.Equal(c, out, "[CMD cat /my status]\n")
}

View file

@ -63,9 +63,9 @@ func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) {
out, _ := dockerCmd(c, "images", "-q", "--no-trunc")
imgs := strings.Split(out, "\n")
assert.Assert(c, imgs[0], checker.Equals, id3, check.Commentf("First image must be %s, got %s", id3, imgs[0]))
assert.Assert(c, imgs[1], checker.Equals, id2, check.Commentf("First image must be %s, got %s", id2, imgs[1]))
assert.Assert(c, imgs[2], checker.Equals, id1, check.Commentf("First image must be %s, got %s", id1, imgs[2]))
assert.Equal(c, imgs[0], id3, check.Commentf("First image must be %s, got %s", id3, imgs[0]))
assert.Equal(c, imgs[1], id2, check.Commentf("First image must be %s, got %s", id2, imgs[1]))
assert.Equal(c, imgs[2], id1, check.Commentf("First image must be %s, got %s", id1, imgs[2]))
}
func (s *DockerSuite) TestImagesErrorWithInvalidFilterNameTest(c *testing.T) {
@ -128,34 +128,34 @@ LABEL number=3`))
expected := []string{imageID3, imageID2}
out, _ := dockerCmd(c, "images", "-f", "since=image:1", "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "since="+imageID1, "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
expected = []string{imageID3}
out, _ = dockerCmd(c, "images", "-f", "since=image:2", "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "since="+imageID2, "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
expected = []string{imageID2, imageID1}
out, _ = dockerCmd(c, "images", "-f", "before=image:3", "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "before="+imageID3, "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
expected = []string{imageID1}
out, _ = dockerCmd(c, "images", "-f", "before=image:2", "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "before="+imageID2, "image")
assert.Assert(c, assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
assert.Equal(c, assertImageList(out, expected), true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
}
func assertImageList(out string, expected []string) bool {
@ -239,7 +239,7 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T)
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=true")
// Expect one dangling image
assert.Assert(c, strings.Count(out, imageID), checker.Equals, 1)
assert.Equal(c, strings.Count(out, imageID), 1)
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=false")
//dangling=false would not include dangling images

View file

@ -114,7 +114,7 @@ func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) {
r := regexp.MustCompile("[\\s]{2,}")
split = r.Split(split[1], -1)
assert.Assert(c, message, checker.Equals, split[3], check.Commentf("didn't get expected value in commit message"))
assert.Equal(c, message, split[3], check.Commentf("didn't get expected value in commit message"))
out, _ = dockerCmd(c, "run", "--rm", image, "true")
assert.Equal(c, out, "", "command output should've been nothing")

View file

@ -60,7 +60,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) {
// TestInfoFormat tests `docker info --format`
func (s *DockerSuite) TestInfoFormat(c *testing.T) {
out, status := dockerCmd(c, "info", "--format", "{{json .}}")
assert.Assert(c, status, checker.Equals, 0)
assert.Equal(c, status, 0)
var m map[string]interface{}
err := json.Unmarshal([]byte(out), &m)
assert.NilError(c, err)

View file

@ -33,13 +33,13 @@ func (s *DockerSuite) TestInspectImage(c *testing.T) {
imageTestID := "sha256:11f64303f0f7ffdc71f001788132bca5346831939a956e3e975c93267d89a16d"
id := inspectField(c, imageTest, "Id")
assert.Assert(c, id, checker.Equals, imageTestID)
assert.Equal(c, id, imageTestID)
}
func (s *DockerSuite) TestInspectInt64(c *testing.T) {
dockerCmd(c, "run", "-d", "-m=300M", "--name", "inspectTest", "busybox", "true")
inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory")
assert.Assert(c, inspectOut, checker.Equals, "314572800")
assert.Equal(c, inspectOut, "314572800")
}
func (s *DockerSuite) TestInspectDefault(c *testing.T) {
@ -50,7 +50,7 @@ func (s *DockerSuite) TestInspectDefault(c *testing.T) {
containerID := strings.TrimSpace(out)
inspectOut := inspectField(c, "busybox", "Id")
assert.Assert(c, strings.TrimSpace(inspectOut), checker.Equals, containerID)
assert.Equal(c, strings.TrimSpace(inspectOut), containerID)
}
func (s *DockerSuite) TestInspectStatus(c *testing.T) {
@ -58,23 +58,23 @@ func (s *DockerSuite) TestInspectStatus(c *testing.T) {
out = strings.TrimSpace(out)
inspectOut := inspectField(c, out, "State.Status")
assert.Assert(c, inspectOut, checker.Equals, "running")
assert.Equal(c, inspectOut, "running")
// Windows does not support pause/unpause on Windows Server Containers.
// (RS1 does for Hyper-V Containers, but production CI is not setup for that)
if testEnv.OSType != "windows" {
dockerCmd(c, "pause", out)
inspectOut = inspectField(c, out, "State.Status")
assert.Assert(c, inspectOut, checker.Equals, "paused")
assert.Equal(c, inspectOut, "paused")
dockerCmd(c, "unpause", out)
inspectOut = inspectField(c, out, "State.Status")
assert.Assert(c, inspectOut, checker.Equals, "running")
assert.Equal(c, inspectOut, "running")
}
dockerCmd(c, "stop", out)
inspectOut = inspectField(c, out, "State.Status")
assert.Assert(c, inspectOut, checker.Equals, "exited")
assert.Equal(c, inspectOut, "exited")
}
@ -120,7 +120,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) {
out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox")
assert.Assert(c, err, checker.NotNil, check.Commentf("%d", exitCode))
assert.Assert(c, exitCode, checker.Equals, 1, check.Commentf("%s", err))
assert.Equal(c, exitCode, 1, check.Commentf("%s", err))
assert.Assert(c, out, checker.Contains, "not a valid value for --type")
}
@ -137,7 +137,7 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) {
out, _ = dockerCmd(c, "inspect", formatStr, imageTest)
result, err := strconv.ParseBool(strings.TrimSuffix(out, "\n"))
assert.NilError(c, err)
assert.Assert(c, result, checker.Equals, true)
assert.Equal(c, result, true)
}
func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) {
@ -159,7 +159,7 @@ func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) {
out, _ = dockerCmd(c, "inspect", formatStr, id)
inspectResult, err := strconv.ParseBool(strings.TrimSuffix(out, "\n"))
assert.NilError(c, err)
assert.Assert(c, inspectResult, checker.Equals, true)
assert.Equal(c, inspectResult, true)
}
func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) {
@ -227,14 +227,14 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) {
m := mp[0]
assert.Assert(c, m.Name, checker.Equals, "")
assert.Assert(c, m.Driver, checker.Equals, "")
assert.Assert(c, m.Source, checker.Equals, prefix+slash+"data")
assert.Assert(c, m.Destination, checker.Equals, prefix+slash+"data")
assert.Equal(c, m.Name, "")
assert.Equal(c, m.Driver, "")
assert.Equal(c, m.Source, prefix+slash+"data")
assert.Equal(c, m.Destination, prefix+slash+"data")
if testEnv.OSType != "windows" { // Windows does not set mode
assert.Assert(c, m.Mode, checker.Equals, "ro"+modifier)
assert.Equal(c, m.Mode, "ro"+modifier)
}
assert.Assert(c, m.RW, checker.Equals, false)
assert.Equal(c, m.RW, false)
}
func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) {
@ -253,11 +253,11 @@ func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) {
m := mp[0]
assert.Assert(c, m.Name, checker.Equals, "data")
assert.Assert(c, m.Driver, checker.Equals, "local")
assert.Equal(c, m.Name, "data")
assert.Equal(c, m.Driver, "local")
assert.Assert(c, m.Source != "")
assert.Assert(c, m.Destination, checker.Equals, prefix+slash+"data")
assert.Assert(c, m.RW, checker.Equals, true)
assert.Equal(c, m.Destination, prefix+slash+"data")
assert.Equal(c, m.RW, true)
}
// #14947
@ -291,8 +291,8 @@ func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) {
err := json.NewDecoder(strings.NewReader(out)).Decode(&logConfig)
assert.Assert(c, err, checker.IsNil, check.Commentf("%v", out))
assert.Assert(c, logConfig.Type, checker.Equals, "json-file")
assert.Assert(c, logConfig.Config["max-file"], checker.Equals, "42", check.Commentf("%v", logConfig))
assert.Equal(c, logConfig.Type, "json-file")
assert.Equal(c, logConfig.Config["max-file"], "42", check.Commentf("%v", logConfig))
}
func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) {
@ -304,7 +304,7 @@ func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) {
formatStr := "--format={{.SizeRw}},{{.SizeRootFs}}"
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "<nil>,<nil>", check.Commentf("Expected not to display size info: %s", out))
assert.Equal(c, strings.TrimSpace(out), "<nil>,<nil>", check.Commentf("Expected not to display size info: %s", out))
}
func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) {
@ -345,10 +345,10 @@ func (s *DockerSuite) TestInspectByPrefix(c *testing.T) {
assert.Assert(c, strings.HasPrefix(id, "sha256:"))
id2 := inspectField(c, id[:12], "Id")
assert.Assert(c, id, checker.Equals, id2)
assert.Equal(c, id, id2)
id3 := inspectField(c, strings.TrimPrefix(id, "sha256:")[:12], "Id")
assert.Assert(c, id, checker.Equals, id3)
assert.Equal(c, id, id3)
}
func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) {

View file

@ -18,7 +18,7 @@ func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) {
_, exitCode, err := dockerCmdWithError("run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
// run ping failed with error
assert.Assert(c, exitCode, checker.Equals, 1, check.Commentf("error: %v", err))
assert.Equal(c, exitCode, 1, check.Commentf("error: %v", err))
}
// Test for appropriate error when calling --link with an invalid target container
@ -173,20 +173,20 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
return string(matches[1])
}
ip := getIP(content, "one")
assert.Assert(c, ip, checker.Equals, realIP)
assert.Equal(c, ip, realIP)
ip = getIP(content, "onetwo")
assert.Assert(c, ip, checker.Equals, realIP)
assert.Equal(c, ip, realIP)
dockerCmd(c, "restart", "one")
realIP = inspectField(c, "one", "NetworkSettings.Networks.bridge.IPAddress")
content = readContainerFileWithExec(c, id, "/etc/hosts")
ip = getIP(content, "one")
assert.Assert(c, ip, checker.Equals, realIP)
assert.Equal(c, ip, realIP)
ip = getIP(content, "onetwo")
assert.Assert(c, ip, checker.Equals, realIP)
assert.Equal(c, ip, realIP)
}
func (s *DockerSuite) TestLinksEnvs(c *testing.T) {
@ -211,7 +211,7 @@ func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) {
assert.Assert(c, waitRun(cid2), checker.IsNil)
links := inspectFieldJSON(c, cid2, "HostConfig.Links")
assert.Assert(c, links, checker.Equals, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
assert.Equal(c, links, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
}
func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) {

View file

@ -360,7 +360,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *testing.T) {
out, _ = dockerCmd(c, "network", "ls", "-f", "label=nonexistent")
outArr := strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("%s\n", out))
assert.Equal(c, len(outArr), 1, check.Commentf("%s\n", out))
out, _ = dockerCmd(c, "network", "ls", "-f", "driver=null")
assertNwList(c, out, []string{"none"})
@ -390,7 +390,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *testing.T) {
out, _, err := dockerCmdWithError("network", "inspect", "--format={{ .Labels."+testLabel+" }}", testNet)
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, testValue)
assert.Equal(c, strings.TrimSpace(out), testValue)
dockerCmd(c, "network", "rm", testNet)
assertNwNotAvailable(c, testNet)
@ -433,7 +433,7 @@ func (s *DockerSuite) TestDockerNetworkInspect(c *testing.T) {
assert.Equal(c, len(networkResources), 1)
out, _ = dockerCmd(c, "network", "inspect", "--format={{ .Name }}", "host")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "host")
assert.Equal(c, strings.TrimSpace(out), "host")
}
func (s *DockerSuite) TestDockerNetworkInspectWithID(c *testing.T) {
@ -441,10 +441,10 @@ func (s *DockerSuite) TestDockerNetworkInspectWithID(c *testing.T) {
networkID := strings.TrimSpace(out)
assertNwIsAvailable(c, "test2")
out, _ = dockerCmd(c, "network", "inspect", "--format={{ .Id }}", "test2")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, networkID)
assert.Equal(c, strings.TrimSpace(out), networkID)
out, _ = dockerCmd(c, "network", "inspect", "--format={{ .ID }}", "test2")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, networkID)
assert.Equal(c, strings.TrimSpace(out), networkID)
}
func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *testing.T) {
@ -541,8 +541,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) {
assertNwIsAvailable(c, "test")
nr := getNwResource(c, "test")
assert.Assert(c, nr.Name, checker.Equals, "test")
assert.Assert(c, len(nr.Containers), checker.Equals, 0)
assert.Equal(c, nr.Name, "test")
assert.Equal(c, len(nr.Containers), 0)
// run a container
out, _ := dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
@ -554,19 +554,19 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) {
// inspect the network to make sure container is connected
nr = getNetworkResource(c, nr.ID)
assert.Assert(c, len(nr.Containers), checker.Equals, 1)
assert.Equal(c, len(nr.Containers), 1)
// check if container IP matches network inspect
ip, _, err := net.ParseCIDR(nr.Containers[containerID].IPv4Address)
assert.NilError(c, err)
containerIP := findContainerIP(c, "test", "test")
assert.Assert(c, ip.String(), checker.Equals, containerIP)
assert.Equal(c, ip.String(), containerIP)
// disconnect container from the network
dockerCmd(c, "network", "disconnect", "test", containerID)
nr = getNwResource(c, "test")
assert.Assert(c, nr.Name, checker.Equals, "test")
assert.Assert(c, len(nr.Containers), checker.Equals, 0)
assert.Equal(c, nr.Name, "test")
assert.Equal(c, len(nr.Containers), 0)
// run another container
out, _ = dockerCmd(c, "run", "-d", "--net", "test", "--name", "test2", "busybox", "top")
@ -574,15 +574,15 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) {
containerID = strings.TrimSpace(out)
nr = getNwResource(c, "test")
assert.Assert(c, nr.Name, checker.Equals, "test")
assert.Assert(c, len(nr.Containers), checker.Equals, 1)
assert.Equal(c, nr.Name, "test")
assert.Equal(c, len(nr.Containers), 1)
// force disconnect the container to the test network
dockerCmd(c, "network", "disconnect", "-f", "test", containerID)
nr = getNwResource(c, "test")
assert.Assert(c, nr.Name, checker.Equals, "test")
assert.Assert(c, len(nr.Containers), checker.Equals, 0)
assert.Equal(c, nr.Name, "test")
assert.Equal(c, len(nr.Containers), 0)
dockerCmd(c, "network", "rm", "test")
assertNwNotAvailable(c, "test")
@ -637,8 +637,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *testing.T) {
// Verify expected network ipam fields are there
nr := getNetworkResource(c, "br0")
assert.Assert(c, nr.Driver, checker.Equals, "bridge")
assert.Assert(c, nr.IPAM.Driver, checker.Equals, dummyIPAMDriver)
assert.Equal(c, nr.Driver, "bridge")
assert.Equal(c, nr.IPAM.Driver, dummyIPAMDriver)
// remove network and exercise remote ipam driver
dockerCmd(c, "network", "rm", "br0")
@ -654,8 +654,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *testing.T) {
// Verify expected network ipam options
nr := getNetworkResource(c, "br0")
opts := nr.IPAM.Options
assert.Assert(c, opts["opt1"], checker.Equals, "drv1")
assert.Assert(c, opts["opt2"], checker.Equals, "drv2")
assert.Equal(c, opts["opt1"], "drv1")
assert.Equal(c, opts["opt2"], "drv2")
}
func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *testing.T) {
@ -668,36 +668,36 @@ func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *testing.T) {
// Verify the inspect data contains the default subnet provided by the null
// ipam driver and no gateway, as the null ipam driver does not provide one
nr := getNetworkResource(c, "test000")
assert.Assert(c, nr.IPAM.Driver, checker.Equals, "null")
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 1)
assert.Assert(c, nr.IPAM.Config[0].Subnet, checker.Equals, "0.0.0.0/0")
assert.Assert(c, nr.IPAM.Config[0].Gateway, checker.Equals, "")
assert.Equal(c, nr.IPAM.Driver, "null")
assert.Equal(c, len(nr.IPAM.Config), 1)
assert.Equal(c, nr.IPAM.Config[0].Subnet, "0.0.0.0/0")
assert.Equal(c, nr.IPAM.Config[0].Gateway, "")
}
func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *testing.T) {
nr := getNetworkResource(c, "none")
assert.Assert(c, nr.Driver, checker.Equals, "null")
assert.Assert(c, nr.Scope, checker.Equals, "local")
assert.Assert(c, nr.Internal, checker.Equals, false)
assert.Assert(c, nr.EnableIPv6, checker.Equals, false)
assert.Assert(c, nr.IPAM.Driver, checker.Equals, "default")
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 0)
assert.Equal(c, nr.Driver, "null")
assert.Equal(c, nr.Scope, "local")
assert.Equal(c, nr.Internal, false)
assert.Equal(c, nr.EnableIPv6, false)
assert.Equal(c, nr.IPAM.Driver, "default")
assert.Equal(c, len(nr.IPAM.Config), 0)
nr = getNetworkResource(c, "host")
assert.Assert(c, nr.Driver, checker.Equals, "host")
assert.Assert(c, nr.Scope, checker.Equals, "local")
assert.Assert(c, nr.Internal, checker.Equals, false)
assert.Assert(c, nr.EnableIPv6, checker.Equals, false)
assert.Assert(c, nr.IPAM.Driver, checker.Equals, "default")
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 0)
assert.Equal(c, nr.Driver, "host")
assert.Equal(c, nr.Scope, "local")
assert.Equal(c, nr.Internal, false)
assert.Equal(c, nr.EnableIPv6, false)
assert.Equal(c, nr.IPAM.Driver, "default")
assert.Equal(c, len(nr.IPAM.Config), 0)
nr = getNetworkResource(c, "bridge")
assert.Assert(c, nr.Driver, checker.Equals, "bridge")
assert.Assert(c, nr.Scope, checker.Equals, "local")
assert.Assert(c, nr.Internal, checker.Equals, false)
assert.Assert(c, nr.EnableIPv6, checker.Equals, false)
assert.Assert(c, nr.IPAM.Driver, checker.Equals, "default")
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 1)
assert.Equal(c, nr.Driver, "bridge")
assert.Equal(c, nr.Scope, "local")
assert.Equal(c, nr.Internal, false)
assert.Equal(c, nr.EnableIPv6, false)
assert.Equal(c, nr.IPAM.Driver, "default")
assert.Equal(c, len(nr.IPAM.Config), 1)
}
func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *testing.T) {
@ -706,12 +706,12 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *testin
assertNwIsAvailable(c, "test01")
nr := getNetworkResource(c, "test01")
assert.Assert(c, nr.Driver, checker.Equals, "bridge")
assert.Assert(c, nr.Scope, checker.Equals, "local")
assert.Assert(c, nr.Internal, checker.Equals, false)
assert.Assert(c, nr.EnableIPv6, checker.Equals, false)
assert.Assert(c, nr.IPAM.Driver, checker.Equals, "default")
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 1)
assert.Equal(c, nr.Driver, "bridge")
assert.Equal(c, nr.Scope, "local")
assert.Equal(c, nr.Internal, false)
assert.Equal(c, nr.EnableIPv6, false)
assert.Equal(c, nr.IPAM.Driver, "default")
assert.Equal(c, len(nr.IPAM.Config), 1)
dockerCmd(c, "network", "rm", "test01")
assertNwNotAvailable(c, "test01")
@ -722,15 +722,15 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomSpecified(c *testing.
assertNwIsAvailable(c, "br0")
nr := getNetworkResource(c, "br0")
assert.Assert(c, nr.Driver, checker.Equals, "bridge")
assert.Assert(c, nr.Scope, checker.Equals, "local")
assert.Assert(c, nr.Internal, checker.Equals, false)
assert.Assert(c, nr.EnableIPv6, checker.Equals, true)
assert.Assert(c, nr.IPAM.Driver, checker.Equals, "default")
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 2)
assert.Assert(c, nr.IPAM.Config[0].Subnet, checker.Equals, "172.28.0.0/16")
assert.Assert(c, nr.IPAM.Config[0].IPRange, checker.Equals, "172.28.5.0/24")
assert.Assert(c, nr.IPAM.Config[0].Gateway, checker.Equals, "172.28.5.254")
assert.Equal(c, nr.Driver, "bridge")
assert.Equal(c, nr.Scope, "local")
assert.Equal(c, nr.Internal, false)
assert.Equal(c, nr.EnableIPv6, true)
assert.Equal(c, nr.IPAM.Driver, "default")
assert.Equal(c, len(nr.IPAM.Config), 2)
assert.Equal(c, nr.IPAM.Config[0].Subnet, "172.28.0.0/16")
assert.Equal(c, nr.IPAM.Config[0].IPRange, "172.28.5.0/24")
assert.Equal(c, nr.IPAM.Config[0].Gateway, "172.28.5.254")
assert.Equal(c, nr.Internal, false)
dockerCmd(c, "network", "rm", "br0")
assertNwNotAvailable(c, "br0")
@ -767,9 +767,9 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *testing.T) {
gopts := remoteDriverNetworkRequest.Options[netlabel.GenericData]
assert.Assert(c, gopts, checker.NotNil)
opts, ok := gopts.(map[string]interface{})
assert.Assert(c, ok, checker.Equals, true)
assert.Assert(c, opts["opt1"], checker.Equals, "drv1")
assert.Assert(c, opts["opt2"], checker.Equals, "drv2")
assert.Equal(c, ok, true)
assert.Equal(c, opts["opt1"], "drv1")
assert.Equal(c, opts["opt2"], "drv2")
dockerCmd(c, "network", "rm", "testopt")
assertNwNotAvailable(c, "testopt")
@ -826,14 +826,14 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *
// verify first container's etc/hosts file has not changed after spawning the second named container
hostsPost, err := s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
assert.Assert(c, string(hosts), checker.Equals, string(hostsPost), check.Commentf("Unexpected %s change on second container creation", hostsFile))
assert.Equal(c, string(hosts), string(hostsPost), check.Commentf("Unexpected %s change on second container creation", hostsFile))
// stop container 2 and verify first container's etc/hosts has not changed
_, err = s.d.Cmd("stop", cid2)
assert.NilError(c, err)
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
assert.Assert(c, string(hosts), checker.Equals, string(hostsPost), check.Commentf("Unexpected %s change on second container creation", hostsFile))
assert.Equal(c, string(hosts), string(hostsPost), check.Commentf("Unexpected %s change on second container creation", hostsFile))
// but discovery is on when connecting to non default bridge network
network := "anotherbridge"
out, err = s.d.Cmd("network", "create", network)
@ -848,7 +848,7 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
assert.Assert(c, string(hosts), checker.Equals, string(hostsPost), check.Commentf("Unexpected %s change on second network connection", hostsFile))
assert.Equal(c, string(hosts), string(hostsPost), check.Commentf("Unexpected %s change on second network connection", hostsFile))
}
func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
@ -871,7 +871,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
// verify first container etc/hosts file has not changed
hosts1post := readContainerFileWithExec(c, cid1, hostsFile)
assert.Assert(c, string(hosts1), checker.Equals, string(hosts1post), check.Commentf("Unexpected %s change on anonymous container creation", hostsFile))
assert.Equal(c, string(hosts1), string(hosts1post), check.Commentf("Unexpected %s change on anonymous container creation", hostsFile))
// Connect the 2nd container to a new network and verify the
// first container /etc/hosts file still hasn't changed.
dockerCmd(c, "network", "create", "-d", "bridge", cstmBridgeNw1)
@ -881,7 +881,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
hosts2 := readContainerFileWithExec(c, cid2, hostsFile)
hosts1post = readContainerFileWithExec(c, cid1, hostsFile)
assert.Assert(c, string(hosts1), checker.Equals, string(hosts1post), check.Commentf("Unexpected %s change on container connect", hostsFile))
assert.Equal(c, string(hosts1), string(hosts1post), check.Commentf("Unexpected %s change on container connect", hostsFile))
// start a named container
cName := "AnyName"
out, _ = dockerCmd(c, "run", "-d", "--net", cstmBridgeNw, "--name", cName, "busybox", "top")
@ -894,9 +894,9 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
// Stop named container and verify first two containers' etc/hosts file hasn't changed
dockerCmd(c, "stop", cid3)
hosts1post = readContainerFileWithExec(c, cid1, hostsFile)
assert.Assert(c, string(hosts1), checker.Equals, string(hosts1post), check.Commentf("Unexpected %s change on name container creation", hostsFile))
assert.Equal(c, string(hosts1), string(hosts1post), check.Commentf("Unexpected %s change on name container creation", hostsFile))
hosts2post := readContainerFileWithExec(c, cid2, hostsFile)
assert.Assert(c, string(hosts2), checker.Equals, string(hosts2post), check.Commentf("Unexpected %s change on name container creation", hostsFile))
assert.Equal(c, string(hosts2), string(hosts2post), check.Commentf("Unexpected %s change on name container creation", hostsFile))
// verify that container 1 and 2 can't ping the named container now
_, _, err := dockerCmdWithError("exec", cid1, "ping", "-c", "1", cName)
assert.ErrorContains(c, err, "")
@ -1010,7 +1010,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *testing.T) {
dockerCmd(c, "run", "-d", "--net", nwn, "--name", ctn, "busybox", "top")
mac := inspectField(c, ctn, "NetworkSettings.Networks."+nwn+".MacAddress")
assert.Assert(c, mac, checker.Equals, "a0:b1:c2:d3:e4:f5")
assert.Equal(c, mac, "a0:b1:c2:d3:e4:f5")
}
func (s *DockerSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
@ -1037,8 +1037,8 @@ func (s *DockerSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
assert.Assert(c, inspect121.NetworkSettings.Networks, checker.HasLen, 3)
bridge := inspect121.NetworkSettings.Networks["bridge"]
assert.Assert(c, bridge.IPAddress, checker.Equals, versionedIP)
assert.Assert(c, bridge.IPAddress, checker.Equals, inspect121.NetworkSettings.IPAddress)
assert.Equal(c, bridge.IPAddress, versionedIP)
assert.Equal(c, bridge.IPAddress, inspect121.NetworkSettings.IPAddress)
}
func connectContainerToNetworks(c *testing.T, d *daemon.Daemon, cName string, nws []string) {
@ -1164,7 +1164,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing.
func verifyPortMap(c *testing.T, container, port, originalMapping string, mustBeEqual bool) {
currentMapping, _ := dockerCmd(c, "port", container, port)
if mustBeEqual {
assert.Assert(c, currentMapping, checker.Equals, originalMapping)
assert.Equal(c, currentMapping, originalMapping)
} else {
assert.Assert(c, currentMapping != originalMapping)
}
@ -1213,7 +1213,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *testing.T) {
dockerCmd(c, "run", "--name=test", "-d", "--mac-address", macAddress, "busybox", "top")
assert.Assert(c, waitRun("test"), checker.IsNil)
mac1 := inspectField(c, "test", "NetworkSettings.Networks.bridge.MacAddress")
assert.Assert(c, strings.TrimSpace(mac1), checker.Equals, macAddress)
assert.Equal(c, strings.TrimSpace(mac1), macAddress)
dockerCmd(c, "network", "connect", "mynetwork", "test")
mac2 := inspectField(c, "test", "NetworkSettings.Networks.mynetwork.MacAddress")
assert.Assert(c, strings.TrimSpace(mac2) != strings.TrimSpace(mac1))
@ -1376,21 +1376,21 @@ func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) {
func verifyIPAddressConfig(c *testing.T, cName, nwname, ipv4, ipv6 string) {
if ipv4 != "" {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv4Address", nwname))
assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv4)
assert.Equal(c, strings.TrimSpace(out), ipv4)
}
if ipv6 != "" {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv6Address", nwname))
assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv6)
assert.Equal(c, strings.TrimSpace(out), ipv6)
}
}
func verifyIPAddresses(c *testing.T, cName, nwname, ipv4, ipv6 string) {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAddress", nwname))
assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv4)
assert.Equal(c, strings.TrimSpace(out), ipv4)
out = inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.GlobalIPv6Address", nwname))
assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv6)
assert.Equal(c, strings.TrimSpace(out), ipv6)
}
func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) {
@ -1612,7 +1612,7 @@ func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T)
assert.ErrorContains(c, err, "")
ns1 := inspectField(c, "bb", "NetworkSettings.Networks.bridge")
assert.Assert(c, ns1, checker.Equals, ns0)
assert.Equal(c, ns1, ns0)
}
func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) {
@ -1717,13 +1717,13 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T)
func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *testing.T) {
dockerCmd(c, "network", "create", "user")
output, status := dockerCmd(c, "run", "--rm", "--network=user", "--network-alias=foo", "busybox", "true")
assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
assert.Equal(c, status, 0, check.Commentf("unexpected status code %d (%s)", status, output))
output, status, _ = dockerCmdWithError("run", "--rm", "--net=user", "--network=user", "busybox", "true")
assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
assert.Equal(c, status, 0, check.Commentf("unexpected status code %d (%s)", status, output))
output, status, _ = dockerCmdWithError("run", "--rm", "--network=user", "--net-alias=foo", "--network-alias=bar", "busybox", "true")
assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
assert.Equal(c, status, 0, check.Commentf("unexpected status code %d (%s)", status, output))
}
func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *testing.T) {

View file

@ -183,12 +183,12 @@ func (ps *DockerPluginSuite) TestPluginSet(c *testing.T) {
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create test plugin"))
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name)
assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=0]")
dockerCmd(c, "plugin", "set", name, "DEBUG=1")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name)
assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
assert.Assert(c, strings.TrimSpace(env), checker.Contains, mntSrc)
@ -221,7 +221,7 @@ func (ps *DockerPluginSuite) TestPluginInstallArgs(c *testing.T) {
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
}
func (ps *DockerPluginSuite) TestPluginInstallImage(c *testing.T) {
@ -289,7 +289,7 @@ func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
assert.NilError(c, err)
assert.Assert(c, out, checker.Contains, name)
// The output will consists of one HEADER line and one line of foo/bar-driver
assert.Assert(c, len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2)
assert.Equal(c, len(strings.Split(strings.TrimSpace(out), "\n")), 2)
}
func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) {
@ -377,12 +377,12 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
assert.Assert(c, out, checker.Contains, "false")
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=0]")
dockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
// Enable
_, _, err = dockerCmdWithError("plugin", "enable", id[:5])

View file

@ -236,9 +236,9 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
expBndRegx2 := regexp.MustCompile(`0.0.0.0:\d\d\d\d\d->` + unpPort2)
out, _ = dockerCmd(c, "ps", "-n=1")
// Cannot find expected port binding port (0.0.0.0:xxxxx->unpPort1) in docker ps output
assert.Assert(c, expBndRegx1.MatchString(out), checker.Equals, true, check.Commentf("out: %s; unpPort1: %s", out, unpPort1))
assert.Equal(c, expBndRegx1.MatchString(out), true, check.Commentf("out: %s; unpPort1: %s", out, unpPort1))
// Cannot find expected port binding port (0.0.0.0:xxxxx->unpPort2) in docker ps output
assert.Assert(c, expBndRegx2.MatchString(out), checker.Equals, true, check.Commentf("out: %s; unpPort2: %s", out, unpPort2))
assert.Equal(c, expBndRegx2.MatchString(out), true, check.Commentf("out: %s; unpPort2: %s", out, unpPort2))
// Run the container specifying explicit port bindings for the exposed ports
offset := 10000
@ -331,7 +331,7 @@ func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "--internal", "-d", "bridge", "internal-net")
nr := getNetworkResource(c, "internal-net")
assert.Assert(c, nr.Internal, checker.Equals, true)
assert.Equal(c, nr.Internal, true)
dockerCmd(c, "run", "--net", "internal-net", "-d", "--name", "c1",
"-p", "8080:8080", "busybox", "nc", "-l", "-p", "8080")

View file

@ -45,79 +45,79 @@ func (s *DockerSuite) TestPsListContainersBase(c *testing.T) {
// all
out, _ = dockerCmd(c, "ps", "-a")
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, thirdID, secondID, firstID}), checker.Equals, true, check.Commentf("ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, thirdID, secondID, firstID}), true, check.Commentf("ALL: Container list is not in the correct order: \n%s", out))
// running
out, _ = dockerCmd(c, "ps")
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, secondID, firstID}), checker.Equals, true, check.Commentf("RUNNING: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, secondID, firstID}), true, check.Commentf("RUNNING: Container list is not in the correct order: \n%s", out))
// limit
out, _ = dockerCmd(c, "ps", "-n=2", "-a")
expected := []string{fourthID, thirdID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("LIMIT & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-n=2")
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("LIMIT: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("LIMIT: Container list is not in the correct order: \n%s", out))
// filter since
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-a")
expected = []string{fourthID, thirdID, secondID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID)
expected = []string{fourthID, secondID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+thirdID)
expected = []string{fourthID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
// filter before
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-a")
expected = []string{thirdID, secondID, firstID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID)
expected = []string{secondID, firstID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("BEFORE filter: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "before="+thirdID)
expected = []string{secondID, firstID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
// filter since & before
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-a")
expected = []string{thirdID, secondID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter, BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID)
expected = []string{secondID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter, BEFORE filter: Container list is not in the correct order: \n%s", out))
// filter since & limit
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-n=2", "-a")
expected = []string{fourthID, thirdID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-n=2")
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter, LIMIT: Container list is not in the correct order: \n%s", out))
// filter before & limit
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-n=1", "-a")
expected = []string{thirdID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-n=1")
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
// filter since & filter before & limit
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-n=1", "-a")
expected = []string{thirdID}
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter, BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-n=1")
assert.Assert(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, check.Commentf("SINCE filter, BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
}
@ -173,7 +173,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *testing.T) {
sizeIndex := strings.Index(lines[0], "SIZE")
idIndex := strings.Index(lines[0], "CONTAINER ID")
foundID := lines[1][idIndex : idIndex+12]
assert.Assert(c, foundID, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
assert.Equal(c, foundID, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
expectedSize := fmt.Sprintf("%dB", 2+baseBytes)
foundSize := lines[1][sizeIndex:]
assert.Assert(c, foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
@ -196,11 +196,11 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) {
// filter containers by exited
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "--filter=status=exited").Combined()
containerOut := strings.TrimSpace(out)
assert.Assert(c, RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, firstID)
assert.Equal(c, RemoveOutputForExistingElements(containerOut, existingContainers), firstID)
out = cli.DockerCmd(c, "ps", "-a", "--no-trunc", "-q", "--filter=status=running").Combined()
containerOut = strings.TrimSpace(out)
assert.Assert(c, RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, secondID)
assert.Equal(c, RemoveOutputForExistingElements(containerOut, existingContainers), secondID)
result := cli.Docker(cli.Args("ps", "-a", "-q", "--filter=status=rubbish"), cli.WithTimeout(time.Second*60))
err := "Invalid filter 'status=rubbish'"
@ -222,7 +222,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) {
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "--filter=status=paused").Combined()
containerOut = strings.TrimSpace(out)
assert.Assert(c, RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, pausedID)
assert.Equal(c, RemoveOutputForExistingElements(containerOut, existingContainers), pausedID)
}
}
@ -236,7 +236,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
out = cli.DockerCmd(c, "ps", "-q", "-l", "--no-trunc", "--filter=health=none").Combined()
containerOut := strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, containerID, check.Commentf("Expected id %s, got %s for legacy none filter, output: %q", containerID, containerOut, out))
assert.Equal(c, containerOut, containerID, check.Commentf("Expected id %s, got %s for legacy none filter, output: %q", containerID, containerOut, out))
// Test no health check specified explicitly
out = runSleepingContainer(c, "--name=none", "--no-healthcheck")
@ -246,7 +246,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
out = cli.DockerCmd(c, "ps", "-q", "-l", "--no-trunc", "--filter=health=none").Combined()
containerOut = strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, containerID, check.Commentf("Expected id %s, got %s for none filter, output: %q", containerID, containerOut, out))
assert.Equal(c, containerOut, containerID, check.Commentf("Expected id %s, got %s for none filter, output: %q", containerID, containerOut, out))
// Test failing health check
out = runSleepingContainer(c, "--name=failing_container", "--health-cmd=exit 1", "--health-interval=1s")
@ -256,7 +256,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
out = cli.DockerCmd(c, "ps", "-q", "--no-trunc", "--filter=health=unhealthy").Combined()
containerOut = strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for unhealthy filter, output: %q", containerID, containerOut, out))
assert.Equal(c, containerOut, containerID, check.Commentf("Expected containerID %s, got %s for unhealthy filter, output: %q", containerID, containerOut, out))
// Check passing healthcheck
out = runSleepingContainer(c, "--name=passing_container", "--health-cmd=exit 0", "--health-interval=1s")
@ -266,7 +266,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
out = cli.DockerCmd(c, "ps", "-q", "--no-trunc", "--filter=health=healthy").Combined()
containerOut = strings.TrimSpace(RemoveOutputForExistingElements(out, existingContainers))
assert.Assert(c, containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out))
assert.Equal(c, containerOut, containerID, check.Commentf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out))
}
func (s *DockerSuite) TestPsListContainersFilterID(c *testing.T) {
@ -280,7 +280,7 @@ func (s *DockerSuite) TestPsListContainersFilterID(c *testing.T) {
// filter containers by id
out, _ = dockerCmd(c, "ps", "-a", "-q", "--filter=id="+firstID)
containerOut := strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, firstID[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out))
assert.Equal(c, containerOut, firstID[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out))
}
func (s *DockerSuite) TestPsListContainersFilterName(c *testing.T) {
@ -294,7 +294,7 @@ func (s *DockerSuite) TestPsListContainersFilterName(c *testing.T) {
// filter containers by name
out, _ := dockerCmd(c, "ps", "-a", "-q", "--filter=name=a_name_to_match")
containerOut := strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", id[:12], containerOut, out))
assert.Equal(c, containerOut, id[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", id[:12], containerOut, out))
}
// Test for the ancestor filter for ps.
@ -396,7 +396,7 @@ func checkPsAncestorFilterOutput(c *testing.T, out string, filterName string, ex
break
}
}
assert.Assert(c, same, checker.Equals, true, check.Commentf("Expected filtered container(s) for %s ancestor filter to be %v, got %v", filterName, expectedIDs, actualIDs))
assert.Equal(c, same, true, check.Commentf("Expected filtered container(s) for %s ancestor filter to be %v, got %v", filterName, expectedIDs, actualIDs))
}
}
@ -416,17 +416,17 @@ func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) {
// filter containers by exact match
out, _ := dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me")
containerOut := strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, firstID, check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
assert.Equal(c, containerOut, firstID, check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
// filter containers by two labels
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me", "--filter=label=second=tag")
containerOut = strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, firstID, check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
assert.Equal(c, containerOut, firstID, check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
// filter containers by two labels, but expect not found because of AND behavior
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me", "--filter=label=second=tag-no")
containerOut = strings.TrimSpace(out)
assert.Assert(c, containerOut, checker.Equals, "", check.Commentf("Expected nothing, got %s for exited filter, output: %q", containerOut, out))
assert.Equal(c, containerOut, "", check.Commentf("Expected nothing, got %s for exited filter, output: %q", containerOut, out))
// filter containers by exact key
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match")
@ -499,11 +499,11 @@ func (s *DockerSuite) TestPsRightTagName(c *testing.T) {
f := strings.Fields(line)
switch f[0] {
case id1:
assert.Assert(c, f[1], checker.Equals, "busybox", check.Commentf("Expected %s tag for id %s, got %s", "busybox", id1, f[1]))
assert.Equal(c, f[1], "busybox", check.Commentf("Expected %s tag for id %s, got %s", "busybox", id1, f[1]))
case id2:
assert.Assert(c, f[1], checker.Equals, tag, check.Commentf("Expected %s tag for id %s, got %s", tag, id2, f[1]))
assert.Equal(c, f[1], tag, check.Commentf("Expected %s tag for id %s, got %s", tag, id2, f[1]))
case id3:
assert.Assert(c, f[1], checker.Equals, imageID, check.Commentf("Expected %s imageID for id %s, got %s", tag, id3, f[1]))
assert.Equal(c, f[1], imageID, check.Commentf("Expected %s imageID for id %s, got %s", tag, id3, f[1]))
default:
c.Fatalf("Unexpected id %s, expected %s and %s and %s", f[0], id1, id2, id3)
}
@ -532,7 +532,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) {
assert.Assert(c, line, checker.Contains, "Created", check.Commentf("Missing 'Created' on '%s'", line))
}
assert.Assert(c, hits, checker.Equals, 1, check.Commentf("Should have seen '%s' in ps -a output once:%d\n%s", shortCID, hits, out))
assert.Equal(c, hits, 1, check.Commentf("Should have seen '%s' in ps -a output once:%d\n%s", shortCID, hits, out))
// filter containers by 'create' - note, no -a needed
out, _ = dockerCmd(c, "ps", "-q", "-f", "status=created")
@ -564,11 +564,11 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
assert.Assert(c, len(lines), checker.Equals, 1)
assert.Equal(c, len(lines), 1)
for _, line := range lines {
f := strings.Fields(line)
assert.Assert(c, f[1], checker.Equals, originalImageName)
assert.Equal(c, f[1], originalImageName)
}
icmd.RunCommand(dockerBinary, "commit", containerID, updatedImageName).Assert(c, icmd.Success)
@ -581,11 +581,11 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
assert.Assert(c, len(lines), checker.Equals, 1)
assert.Equal(c, len(lines), 1)
for _, line := range lines {
f := strings.Fields(line)
assert.Assert(c, f[1], checker.Equals, originalImageID)
assert.Equal(c, f[1], originalImageID)
}
}
@ -598,7 +598,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
expected := "0.0.0.0:5000->5000/tcp"
fields := strings.Fields(lines[1])
assert.Assert(c, fields[len(fields)-2], checker.Equals, expected, check.Commentf("Expected: %v, got: %v", expected, fields[len(fields)-2]))
assert.Equal(c, fields[len(fields)-2], expected, check.Commentf("Expected: %v, got: %v", expected, fields[len(fields)-2]))
dockerCmd(c, "kill", "foo")
dockerCmd(c, "wait", "foo")
@ -642,8 +642,8 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
fields := strings.Fields(lines[0])
assert.Equal(c, len(fields), 2)
assert.Assert(c, fields[0], checker.Equals, "bind-mount-test")
assert.Assert(c, fields[1], checker.Equals, bindMountSource)
assert.Equal(c, fields[0], "bind-mount-test")
assert.Equal(c, fields[1], bindMountSource)
fields = strings.Fields(lines[1])
assert.Equal(c, len(fields), 2)
@ -651,7 +651,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
anonymousVolumeID := fields[1]
fields = strings.Fields(lines[2])
assert.Assert(c, fields[1], checker.Equals, "ps-volume-test")
assert.Equal(c, fields[1], "ps-volume-test")
// filter by volume name
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=ps-volume-test")
@ -661,7 +661,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
assert.Equal(c, len(lines), 1)
fields = strings.Fields(lines[0])
assert.Assert(c, fields[1], checker.Equals, "ps-volume-test")
assert.Equal(c, fields[1], "ps-volume-test")
// empty results filtering by unknown volume
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=this-volume-should-not-exist")
@ -675,9 +675,9 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
assert.Equal(c, len(lines), 2)
fields = strings.Fields(lines[0])
assert.Assert(c, fields[1], checker.Equals, anonymousVolumeID)
assert.Equal(c, fields[1], anonymousVolumeID)
fields = strings.Fields(lines[1])
assert.Assert(c, fields[1], checker.Equals, "ps-volume-test")
assert.Equal(c, fields[1], "ps-volume-test")
// filter by bind mount source
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource)
@ -688,8 +688,8 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
fields = strings.Fields(lines[0])
assert.Equal(c, len(fields), 2)
assert.Assert(c, fields[0], checker.Equals, "bind-mount-test")
assert.Assert(c, fields[1], checker.Equals, bindMountSource)
assert.Equal(c, fields[0], "bind-mount-test")
assert.Equal(c, fields[1], bindMountSource)
// filter by bind mount destination
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination)
@ -700,8 +700,8 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
fields = strings.Fields(lines[0])
assert.Equal(c, len(fields), 2)
assert.Assert(c, fields[0], checker.Equals, "bind-mount-test")
assert.Assert(c, fields[1], checker.Equals, bindMountSource)
assert.Equal(c, fields[0], "bind-mount-test")
assert.Equal(c, fields[1], bindMountSource)
// empty results filtering by unknown mount point
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+prefix+slash+"this-path-was-never-mounted")

View file

@ -42,23 +42,23 @@ func (s *DockerSuite) TestRmiTag(c *testing.T) {
dockerCmd(c, "tag", "busybox", "utest:5000/docker:tag3")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
assert.Assert(c, strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+3, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+3, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
dockerCmd(c, "rmi", "utest/docker:tag2")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
assert.Assert(c, strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+2, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+2, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
dockerCmd(c, "rmi", "utest:5000/docker:tag3")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
assert.Assert(c, strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+1, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+1, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
dockerCmd(c, "rmi", "utest:tag1")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
assert.Assert(c, strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n"), check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n"), check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
}
@ -81,7 +81,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *testing.T) {
imagesAfter := cli.DockerCmd(c, "images", "-a").Combined()
// tag busybox to create 2 more images with same imageID
assert.Assert(c, strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+2, check.Commentf("docker images shows: %q\n", imagesAfter))
assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+2, check.Commentf("docker images shows: %q\n", imagesAfter))
imgID := inspectField(c, "busybox-one:tag1", "Id")
@ -123,7 +123,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) {
cli.DockerCmd(c, "tag", "busybox-test", "utest:5000/docker:tag4")
{
imagesAfter := cli.DockerCmd(c, "images", "-a").Combined()
assert.Assert(c, strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+4, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+4, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
imgID := inspectField(c, "busybox-test", "Id")
@ -166,7 +166,7 @@ func (s *DockerSuite) TestRmiTagWithExistingContainers(c *testing.T) {
dockerCmd(c, "run", "--name", container, bb, "/bin/true")
out, _ := dockerCmd(c, "rmi", newtag)
assert.Assert(c, strings.Count(out, "Untagged: "), checker.Equals, 1)
assert.Equal(c, strings.Count(out, "Untagged: "), 1)
}
func (s *DockerSuite) TestRmiForceWithExistingContainers(c *testing.T) {
@ -274,7 +274,7 @@ RUN echo 2 #layer2
// See if the "tmp2" can be untagged.
out, _ = dockerCmd(c, "rmi", newTag)
// Expected 1 untagged entry
assert.Assert(c, strings.Count(out, "Untagged: "), checker.Equals, 1, check.Commentf("out: %s", out))
assert.Equal(c, strings.Count(out, "Untagged: "), 1, check.Commentf("out: %s", out))
// Now let's add the tag again and create a container based on it.
dockerCmd(c, "tag", idToTag, newTag)
@ -335,5 +335,5 @@ func (s *DockerSuite) TestRmiByIDHardConflict(c *testing.T) {
// check that tag was not removed
imgID2 := inspectField(c, "busybox:latest", "Id")
assert.Assert(c, imgID, checker.Equals, imgID2)
assert.Equal(c, imgID, imgID2)
}

View file

@ -3212,7 +3212,7 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) {
containerID, err := inspectFieldWithError(name, "Id")
assert.Assert(c, err, checker.NotNil, check.Commentf("Expected not to have this container: %s!", containerID))
assert.Assert(c, containerID, checker.Equals, "", check.Commentf("Expected not to have this container: %s!", containerID))
assert.Equal(c, containerID, "", check.Commentf("Expected not to have this container: %s!", containerID))
}
func (s *DockerSuite) TestRunNamedVolume(c *testing.T) {
@ -3221,10 +3221,10 @@ func (s *DockerSuite) TestRunNamedVolume(c *testing.T) {
dockerCmd(c, "run", "--name=test", "-v", "testing:"+prefix+"/foo", "busybox", "sh", "-c", "echo hello > "+prefix+"/foo/bar")
out, _ := dockerCmd(c, "run", "--volumes-from", "test", "busybox", "sh", "-c", "cat "+prefix+"/foo/bar")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello")
assert.Equal(c, strings.TrimSpace(out), "hello")
out, _ = dockerCmd(c, "run", "-v", "testing:"+prefix+"/foo", "busybox", "sh", "-c", "cat "+prefix+"/foo/bar")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello")
assert.Equal(c, strings.TrimSpace(out), "hello")
}
func (s *DockerSuite) TestRunWithUlimits(c *testing.T) {
@ -3870,7 +3870,7 @@ func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *testing.T) {
dockerCmd(c, "run", "-v", "foo:/foo", testImg)
out, _ := dockerCmd(c, "run", "-v", "foo:/foo", "busybox", "cat", "/foo/hello")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello")
assert.Equal(c, strings.TrimSpace(out), "hello")
}
func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *testing.T) {
@ -4054,7 +4054,7 @@ func (s *DockerSuite) TestRunRmAndWait(c *testing.T) {
out, code, err := dockerCmdWithError("wait", "test")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %s; exit code: %d", out, code))
assert.Equal(c, out, "2\n", "exit code: %d", code)
assert.Assert(c, code, checker.Equals, 0)
assert.Equal(c, code, 0)
}
// Test that auto-remove is performed by the daemon (API 1.25 and above)
@ -4102,7 +4102,7 @@ exec "$@"`,
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "--entrypoint=", "-t", name, "echo", "foo").Combined()
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "foo")
assert.Equal(c, strings.TrimSpace(out), "foo")
// CMD will be reset as well (the same as setting a custom entrypoint)
cli.Docker(cli.Args("run", "--entrypoint=", "-t", name)).Assert(c, icmd.Expected{

View file

@ -137,7 +137,7 @@ func (s *DockerSuite) TestRunAttachDetach(c *testing.T) {
}
running := inspectField(c, name, "State.Running")
assert.Assert(c, running, checker.Equals, "true", check.Commentf("expected container to still be running"))
assert.Equal(c, running, "true", check.Commentf("expected container to still be running"))
out, _ = dockerCmd(c, "events", "--since=0", "--until", daemonUnixTime(c), "-f", "container="+name)
// attach and detach event should be monitored
@ -203,7 +203,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) {
}
running := inspectField(c, name, "State.Running")
assert.Assert(c, running, checker.Equals, "true", check.Commentf("expected container to still be running"))
assert.Equal(c, running, "true", check.Commentf("expected container to still be running"))
}
// TestRunAttachDetachFromInvalidFlag checks attaching and detaching with the escape sequence specified via flags.
@ -319,7 +319,7 @@ func (s *DockerSuite) TestRunAttachDetachFromConfig(c *testing.T) {
}
running := inspectField(c, name, "State.Running")
assert.Assert(c, running, checker.Equals, "true", check.Commentf("expected container to still be running"))
assert.Equal(c, running, "true", check.Commentf("expected container to still be running"))
}
// TestRunAttachDetachKeysOverrideConfig checks attaching and detaching with the detach flags, making sure it overrides config file
@ -402,7 +402,7 @@ func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) {
}
running := inspectField(c, name, "State.Running")
assert.Assert(c, running, checker.Equals, "true", check.Commentf("expected container to still be running"))
assert.Equal(c, running, "true", check.Commentf("expected container to still be running"))
}
func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.T) {
@ -793,7 +793,7 @@ func (s *DockerSuite) TestRunWithDefaultShmSize(c *testing.T) {
c.Fatalf("Expected shm of 64MB in mount command, got %v", out)
}
shmSize := inspectField(c, name, "HostConfig.ShmSize")
assert.Assert(c, shmSize, checker.Equals, "67108864")
assert.Equal(c, shmSize, "67108864")
}
func (s *DockerSuite) TestRunWithShmSize(c *testing.T) {
@ -806,7 +806,7 @@ func (s *DockerSuite) TestRunWithShmSize(c *testing.T) {
c.Fatalf("Expected shm of 1GB in mount command, got %v", out)
}
shmSize := inspectField(c, name, "HostConfig.ShmSize")
assert.Assert(c, shmSize, checker.Equals, "1073741824")
assert.Equal(c, shmSize, "1073741824")
}
func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) {
@ -895,23 +895,23 @@ func (s *DockerSuite) TestRunSysctls(c *testing.T) {
var err error
out, _ := dockerCmd(c, "run", "--sysctl", "net.ipv4.ip_forward=1", "--name", "test", "busybox", "cat", "/proc/sys/net/ipv4/ip_forward")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "1")
assert.Equal(c, strings.TrimSpace(out), "1")
out = inspectFieldJSON(c, "test", "HostConfig.Sysctls")
sysctls := make(map[string]string)
err = json.Unmarshal([]byte(out), &sysctls)
assert.NilError(c, err)
assert.Assert(c, sysctls["net.ipv4.ip_forward"], checker.Equals, "1")
assert.Equal(c, sysctls["net.ipv4.ip_forward"], "1")
out, _ = dockerCmd(c, "run", "--sysctl", "net.ipv4.ip_forward=0", "--name", "test1", "busybox", "cat", "/proc/sys/net/ipv4/ip_forward")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "0")
assert.Equal(c, strings.TrimSpace(out), "0")
out = inspectFieldJSON(c, "test1", "HostConfig.Sysctls")
err = json.Unmarshal([]byte(out), &sysctls)
assert.NilError(c, err)
assert.Assert(c, sysctls["net.ipv4.ip_forward"], checker.Equals, "0")
assert.Equal(c, sysctls["net.ipv4.ip_forward"], "0")
icmd.RunCommand(dockerBinary, "run", "--sysctl", "kernel.foobar=1", "--name", "test2",
"busybox", "cat", "/proc/sys/kernel/foobar").Assert(c, icmd.Expected{
@ -1577,7 +1577,7 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *testing.T) {
assert.NilError(c, err)
inspect, err := clt.ContainerInspect(context.Background(), "test")
assert.NilError(c, err)
assert.Assert(c, inspect.HostConfig.NanoCPUs, checker.Equals, int64(500000000))
assert.Equal(c, inspect.HostConfig.NanoCPUs, int64(500000000))
out = inspectField(c, "test", "HostConfig.CpuQuota")
assert.Equal(c, out, "0", "CPU CFS quota should be 0")

View file

@ -44,9 +44,9 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig), checker.IsNil)
assert.Assert(c, mountConfig, checker.HasLen, 1)
assert.Assert(c, mountConfig[0].Source, checker.Equals, "foo")
assert.Assert(c, mountConfig[0].Target, checker.Equals, "/foo")
assert.Assert(c, mountConfig[0].Type, checker.Equals, mount.TypeVolume)
assert.Equal(c, mountConfig[0].Source, "foo")
assert.Equal(c, mountConfig[0].Target, "/foo")
assert.Equal(c, mountConfig[0].Type, mount.TypeVolume)
assert.Assert(c, mountConfig[0].VolumeOptions, checker.NotNil)
assert.Assert(c, mountConfig[0].VolumeOptions.NoCopy, checker.True)
@ -58,10 +58,10 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &mounts), checker.IsNil)
assert.Assert(c, mounts, checker.HasLen, 1)
assert.Assert(c, mounts[0].Type, checker.Equals, mount.TypeVolume)
assert.Assert(c, mounts[0].Name, checker.Equals, "foo")
assert.Assert(c, mounts[0].Destination, checker.Equals, "/foo")
assert.Assert(c, mounts[0].RW, checker.Equals, true)
assert.Equal(c, mounts[0].Type, mount.TypeVolume)
assert.Equal(c, mounts[0].Name, "foo")
assert.Equal(c, mounts[0].Destination, "/foo")
assert.Equal(c, mounts[0].RW, true)
}
func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *testing.T) {
@ -87,11 +87,11 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Equal(c, len(refs), 1)
assert.Assert(c, refs[0].SecretName, checker.Equals, testName)
assert.Equal(c, refs[0].SecretName, testName)
assert.Assert(c, refs[0].File != nil)
assert.Assert(c, refs[0].File.Name, checker.Equals, testName)
assert.Assert(c, refs[0].File.UID, checker.Equals, "0")
assert.Assert(c, refs[0].File.GID, checker.Equals, "0")
assert.Equal(c, refs[0].File.Name, testName)
assert.Equal(c, refs[0].File.UID, "0")
assert.Equal(c, refs[0].File.GID, "0")
out, err = d.Cmd("service", "rm", serviceName)
assert.NilError(c, err, out)
@ -235,11 +235,11 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Equal(c, len(refs), 1)
assert.Assert(c, refs[0].ConfigName, checker.Equals, testName)
assert.Equal(c, refs[0].ConfigName, testName)
assert.Assert(c, refs[0].File != nil)
assert.Assert(c, refs[0].File.Name, checker.Equals, testName)
assert.Assert(c, refs[0].File.UID, checker.Equals, "0")
assert.Assert(c, refs[0].File.GID, checker.Equals, "0")
assert.Equal(c, refs[0].File.Name, testName)
assert.Equal(c, refs[0].File.UID, "0")
assert.Equal(c, refs[0].File.GID, "0")
out, err = d.Cmd("service", "rm", serviceName)
assert.NilError(c, err, out)
@ -387,11 +387,11 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig), checker.IsNil)
assert.Assert(c, mountConfig, checker.HasLen, 1)
assert.Assert(c, mountConfig[0].Source, checker.Equals, "")
assert.Assert(c, mountConfig[0].Target, checker.Equals, "/foo")
assert.Assert(c, mountConfig[0].Type, checker.Equals, mount.TypeTmpfs)
assert.Equal(c, mountConfig[0].Source, "")
assert.Equal(c, mountConfig[0].Target, "/foo")
assert.Equal(c, mountConfig[0].Type, mount.TypeTmpfs)
assert.Assert(c, mountConfig[0].TmpfsOptions, checker.NotNil)
assert.Assert(c, mountConfig[0].TmpfsOptions.SizeBytes, checker.Equals, int64(1048576))
assert.Equal(c, mountConfig[0].TmpfsOptions.SizeBytes, int64(1048576))
// check container mounts actual
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID)
@ -401,10 +401,10 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
assert.Assert(c, json.Unmarshal([]byte(out), &mounts), checker.IsNil)
assert.Assert(c, mounts, checker.HasLen, 1)
assert.Assert(c, mounts[0].Type, checker.Equals, mount.TypeTmpfs)
assert.Assert(c, mounts[0].Name, checker.Equals, "")
assert.Assert(c, mounts[0].Destination, checker.Equals, "/foo")
assert.Assert(c, mounts[0].RW, checker.Equals, true)
assert.Equal(c, mounts[0].Type, mount.TypeTmpfs)
assert.Equal(c, mounts[0].Name, "")
assert.Equal(c, mounts[0].Destination, "/foo")
assert.Equal(c, mounts[0].RW, true)
out, err = s.nodeCmd(c, task.NodeID, "logs", task.Status.ContainerStatus.ContainerID)
assert.NilError(c, err, out)

View file

@ -124,7 +124,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
// task should be blocked at starting status
task = d.GetTask(c, task.ID)
assert.Assert(c, task.Status.State, checker.Equals, swarm.TaskStateStarting)
assert.Equal(c, task.Status.State, swarm.TaskStateStarting)
// make it healthy
d.Cmd("exec", containerID, "touch", "/status")

View file

@ -64,7 +64,7 @@ func (s *DockerSuite) TestStartAttachSilent(c *testing.T) {
startOut, _ := dockerCmd(c, "start", "-a", name)
// start -a produced unexpected output
assert.Assert(c, startOut, checker.Equals, "test\n")
assert.Equal(c, startOut, "test\n")
}
func (s *DockerSuite) TestStartRecordError(c *testing.T) {
@ -74,7 +74,7 @@ func (s *DockerSuite) TestStartRecordError(c *testing.T) {
dockerCmd(c, "run", "-d", "-p", "9999:9999", "--name", "test", "busybox", "top")
stateErr := inspectField(c, "test", "State.Error")
// Expected to not have state error
assert.Assert(c, stateErr, checker.Equals, "")
assert.Equal(c, stateErr, "")
// Expect this to fail and records error because of ports conflict
out, _, err := dockerCmdWithError("run", "-d", "--name", "test2", "-p", "9999:9999", "busybox", "top")
@ -89,7 +89,7 @@ func (s *DockerSuite) TestStartRecordError(c *testing.T) {
dockerCmd(c, "start", "test2")
stateErr = inspectField(c, "test2", "State.Error")
// Expected to not have state error but got one
assert.Assert(c, stateErr, checker.Equals, "")
assert.Equal(c, stateErr, "")
}
func (s *DockerSuite) TestStartPausedContainer(c *testing.T) {
@ -193,9 +193,9 @@ func (s *DockerSuite) TestStartReturnCorrectExitCode(c *testing.T) {
out, exitCode, err := dockerCmdWithError("start", "-a", "withRestart")
assert.ErrorContains(c, err, "")
assert.Assert(c, exitCode, checker.Equals, 11, check.Commentf("out: %s", out))
assert.Equal(c, exitCode, 11, check.Commentf("out: %s", out))
out, exitCode, err = dockerCmdWithError("start", "-a", "withRm")
assert.ErrorContains(c, err, "")
assert.Assert(c, exitCode, checker.Equals, 12, check.Commentf("out: %s", out))
assert.Equal(c, exitCode, 12, check.Commentf("out: %s", out))
}

View file

@ -46,15 +46,15 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *testing.T) {
assert.NilError(c, err, out)
spec := getSpec()
assert.Assert(c, spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
assert.Assert(c, spec.Dispatcher.HeartbeatPeriod, checker.Equals, 11*time.Second)
assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
assert.Equal(c, spec.Dispatcher.HeartbeatPeriod, 11*time.Second)
// setting anything under 30m for cert-expiry is not allowed
out, err = d.Cmd("swarm", "update", "--cert-expiry", "15m")
assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "minimum certificate expiry time")
spec = getSpec()
assert.Assert(c, spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
// passing an external CA (this is without starting a root rotation) does not fail
cli.Docker(cli.Args("swarm", "update", "--external-ca", "protocol=cfssl,url=https://something.org",
@ -66,8 +66,8 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *testing.T) {
spec = getSpec()
assert.Assert(c, spec.CAConfig.ExternalCAs, checker.HasLen, 2)
assert.Assert(c, spec.CAConfig.ExternalCAs[0].CACert, checker.Equals, "")
assert.Assert(c, spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected))
assert.Equal(c, spec.CAConfig.ExternalCAs[0].CACert, "")
assert.Equal(c, spec.CAConfig.ExternalCAs[1].CACert, string(expected))
// passing an invalid external CA fails
tempFile := fs.NewFile(c, "testfile", fs.WithContent("fakecert"))
@ -111,18 +111,18 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
assert.NilError(c, err)
spec := getSpec()
assert.Assert(c, spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
assert.Assert(c, spec.Dispatcher.HeartbeatPeriod, checker.Equals, 11*time.Second)
assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
assert.Equal(c, spec.Dispatcher.HeartbeatPeriod, 11*time.Second)
assert.Assert(c, spec.CAConfig.ExternalCAs, checker.HasLen, 2)
assert.Assert(c, spec.CAConfig.ExternalCAs[0].CACert, checker.Equals, "")
assert.Assert(c, spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected))
assert.Equal(c, spec.CAConfig.ExternalCAs[0].CACert, "")
assert.Equal(c, spec.CAConfig.ExternalCAs[1].CACert, string(expected))
assert.Assert(c, d.SwarmLeave(c, true), checker.IsNil)
cli.Docker(cli.Args("swarm", "init"), cli.Daemon(d)).Assert(c, icmd.Success)
spec = getSpec()
assert.Assert(c, spec.CAConfig.NodeCertExpiry, checker.Equals, 90*24*time.Hour)
assert.Assert(c, spec.Dispatcher.HeartbeatPeriod, checker.Equals, 5*time.Second)
assert.Equal(c, spec.CAConfig.NodeCertExpiry, 90*24*time.Hour)
assert.Equal(c, spec.Dispatcher.HeartbeatPeriod, 5*time.Second)
}
func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *testing.T) {
@ -182,7 +182,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *testing.T) {
containers := d.ActiveContainers(c)
out, err = d.Cmd("inspect", "--type", "container", "--format", "{{.Config.Hostname}}", containers[0])
assert.NilError(c, err, out)
assert.Assert(c, strings.Split(out, "\n")[0], checker.Equals, "test-1-"+strings.Split(hostname, "\n")[0], check.Commentf("hostname with templating invalid"))
assert.Equal(c, strings.Split(out, "\n")[0], "test-1-"+strings.Split(hostname, "\n")[0], check.Commentf("hostname with templating invalid"))
}
// Test case for #24270
@ -619,7 +619,7 @@ func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
out, err = d.Cmd("ps", "-a", "-q", "--filter=is-task=false")
assert.NilError(c, err, out)
psOut := strings.TrimSpace(out)
assert.Assert(c, psOut, checker.Equals, bareID, check.Commentf("Expected id %s, got %s for is-task label, output %q", bareID, psOut, out))
assert.Equal(c, psOut, bareID, check.Commentf("Expected id %s, got %s for is-task label, output %q", bareID, psOut, out))
// Filter tasks
out, err = d.Cmd("ps", "-a", "-q", "--filter=is-task=true")
@ -1062,11 +1062,11 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
unlockKey := getUnlockKey(d, c, outs)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
// It starts off locked
d.RestartNode(c)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString("wrong-secret-key")
@ -1075,13 +1075,13 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
Err: "invalid key",
})
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
cmd = d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
outs, err = d.Cmd("node", "ls")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
@ -1137,7 +1137,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
// they start off unlocked
d2.RestartNode(c)
assert.Assert(c, getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateActive)
// stop this one so it does not get autolock info
d2.Stop(c)
@ -1154,12 +1154,12 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
}
// d2 never got the cluster update, so it is still set to unlocked
d2.StartNode(c)
assert.Assert(c, getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateActive)
// d2 is now set to lock
checkSwarmUnlockedToLocked(c, d2)
@ -1174,13 +1174,13 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
}
// d2 still locked
assert.Assert(c, getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateLocked)
assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateLocked)
// unlock it
cmd := d2.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateActive)
// once it's caught up, d2 is set to not be locked
checkSwarmLockedToUnlocked(c, d2)
@ -1188,7 +1188,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
// managers who join now are never set to locked in the first place
d4 := s.AddDaemon(c, true, true)
d4.RestartNode(c)
assert.Assert(c, getNodeStatus(c, d4), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d4), swarm.LocalNodeStateActive)
}
func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
@ -1219,7 +1219,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
}
// demote manager back to worker - workers are not locked
@ -1267,7 +1267,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
assert.Assert(c, newUnlockKey != unlockKey)
d.RestartNode(c)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
outs, _ = d.Cmd("node", "ls")
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
@ -1305,7 +1305,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
cmd.Stdin = bytes.NewBufferString(newUnlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
retry := 0
for {
@ -1359,7 +1359,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
d3.RestartNode(c)
for _, d := range []*daemon.Daemon{d2, d3} {
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
outs, _ := d.Cmd("node", "ls")
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
@ -1397,7 +1397,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
cmd.Stdin = bytes.NewBufferString(newUnlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
retry := 0
for {
@ -1436,7 +1436,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
assert.Assert(c, getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
outs, err = d.Cmd("swarm", "update", "--autolock=false")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))

View file

@ -51,13 +51,13 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
assert.NilError(c, err, "Output: %s", out)
user := s.findUser(c, "userns")
assert.Assert(c, uidgid[0], checker.Equals, user)
assert.Equal(c, uidgid[0], user)
// check that the created directory is owned by remapped uid:gid
statNotExists, err := system.Stat(tmpDirNotExists)
assert.NilError(c, err)
assert.Assert(c, statNotExists.UID(), checker.Equals, uint32(uid), check.Commentf("Created directory not owned by remapped root UID"))
assert.Assert(c, statNotExists.GID(), checker.Equals, uint32(gid), check.Commentf("Created directory not owned by remapped root GID"))
assert.Equal(c, statNotExists.UID(), uint32(uid), check.Commentf("Created directory not owned by remapped root UID"))
assert.Equal(c, statNotExists.GID(), uint32(gid), check.Commentf("Created directory not owned by remapped root GID"))
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
assert.Assert(c, err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid))
@ -76,15 +76,15 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
// check that the touched file is owned by remapped uid:gid
stat, err := system.Stat(filepath.Join(tmpDir, "testfile"))
assert.NilError(c, err)
assert.Assert(c, stat.UID(), checker.Equals, uint32(uid), check.Commentf("Touched file not owned by remapped root UID"))
assert.Assert(c, stat.GID(), checker.Equals, uint32(gid), check.Commentf("Touched file not owned by remapped root GID"))
assert.Equal(c, stat.UID(), uint32(uid), check.Commentf("Touched file not owned by remapped root UID"))
assert.Equal(c, stat.GID(), uint32(gid), check.Commentf("Touched file not owned by remapped root GID"))
// use host usernamespace
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; top")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out))
user = s.findUser(c, "userns_skip")
// userns are skipped, user is root
assert.Assert(c, user, checker.Equals, "root")
assert.Equal(c, user, "root")
}
// findUser finds the uid or name of the user of the first process that runs in a container

View file

@ -29,11 +29,11 @@ func (s *DockerSuite) TestVolumeCLICreate(c *testing.T) {
// test using hidden --name option
out, _ := dockerCmd(c, "volume", "create", "--name=test")
name := strings.TrimSpace(out)
assert.Assert(c, name, checker.Equals, "test")
assert.Equal(c, name, "test")
out, _ = dockerCmd(c, "volume", "create", "test2")
name = strings.TrimSpace(out)
assert.Assert(c, name, checker.Equals, "test2")
assert.Equal(c, name, "test2")
}
func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) {
@ -41,11 +41,11 @@ func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create")
name := strings.TrimSpace(out)
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", name)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, name)
assert.Equal(c, strings.TrimSpace(out), name)
dockerCmd(c, "volume", "create", "test")
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", "test")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "test")
assert.Equal(c, strings.TrimSpace(out), "test")
}
func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) {
@ -200,13 +200,13 @@ func (s *DockerSuite) TestVolumeCLIRm(c *testing.T) {
})
out, _ = dockerCmd(c, "run", "--volumes-from=test", "--name=test2", "busybox", "sh", "-c", "cat /foo/bar")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello")
assert.Equal(c, strings.TrimSpace(out), "hello")
dockerCmd(c, "rm", "-fv", "test2")
dockerCmd(c, "volume", "inspect", volumeID)
dockerCmd(c, "rm", "-f", "test")
out, _ = dockerCmd(c, "run", "--name=test2", "-v", volumeID+":"+prefix+"/foo", "busybox", "sh", "-c", "cat /foo/bar")
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello", check.Commentf("volume data was removed"))
assert.Equal(c, strings.TrimSpace(out), "hello", check.Commentf("volume data was removed"))
dockerCmd(c, "rm", "test2")
dockerCmd(c, "volume", "rm", volumeID)
@ -243,7 +243,7 @@ func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) {
out, exitCode, err := dockerCmdWithError("volume", "inspect", "--format='{{ .FooBar }}'", name)
assert.Assert(c, err, checker.NotNil, check.Commentf("Output: %s", out))
assert.Assert(c, exitCode, checker.Equals, 1, check.Commentf("Output: %s", out))
assert.Equal(c, exitCode, 1, check.Commentf("Output: %s", out))
assert.Assert(c, out, checker.Contains, "Template parsing error")
}
@ -260,15 +260,15 @@ func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) {
found = true
info := strings.Fields(m)
// tmpfs on <path> type tmpfs (rw,relatime,size=1024k,uid=1000)
assert.Assert(c, info[0], checker.Equals, "tmpfs")
assert.Assert(c, info[2], checker.Equals, "/foo")
assert.Assert(c, info[4], checker.Equals, "tmpfs")
assert.Equal(c, info[0], "tmpfs")
assert.Equal(c, info[2], "/foo")
assert.Equal(c, info[4], "tmpfs")
assert.Assert(c, info[5], checker.Contains, "uid=1000")
assert.Assert(c, info[5], checker.Contains, "size=1024k")
break
}
}
assert.Assert(c, found, checker.Equals, true)
assert.Equal(c, found, true)
}
func (s *DockerSuite) TestVolumeCLICreateLabel(c *testing.T) {
@ -280,7 +280,7 @@ func (s *DockerSuite) TestVolumeCLICreateLabel(c *testing.T) {
assert.NilError(c, err)
out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+testLabel+" }}", testVol)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, testValue)
assert.Equal(c, strings.TrimSpace(out), testValue)
}
func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) {
@ -306,7 +306,7 @@ func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) {
for k, v := range testLabels {
out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+k+" }}", testVol)
assert.Assert(c, strings.TrimSpace(out), checker.Equals, v)
assert.Equal(c, strings.TrimSpace(out), v)
}
}
@ -333,11 +333,11 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) {
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=non-exist")
outArr := strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("\n%s", out))
assert.Equal(c, len(outArr), 1, check.Commentf("\n%s", out))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo=non-exist")
outArr = strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("\n%s", out))
assert.Equal(c, len(outArr), 1, check.Commentf("\n%s", out))
}
func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *testing.T) {
@ -358,17 +358,17 @@ func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *testing.T) {
// filter with driver=invaliddriver
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=invaliddriver")
outArr := strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("\n%s", out))
assert.Equal(c, len(outArr), 1, check.Commentf("\n%s", out))
// filter with driver=loca
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=loca")
outArr = strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("\n%s", out))
assert.Equal(c, len(outArr), 1, check.Commentf("\n%s", out))
// filter with driver=
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=")
outArr = strings.Split(strings.TrimSpace(out), "\n")
assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("\n%s", out))
assert.Equal(c, len(outArr), 1, check.Commentf("\n%s", out))
}
func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *testing.T) {
@ -385,7 +385,7 @@ func (s *DockerSuite) TestVolumeCLIRmForce(c *testing.T) {
name := "test"
out, _ := dockerCmd(c, "volume", "create", name)
id := strings.TrimSpace(out)
assert.Assert(c, id, checker.Equals, name)
assert.Equal(c, id, name)
out, _ = dockerCmd(c, "volume", "inspect", "--format", "{{.Mountpoint}}", name)
assert.Assert(c, strings.TrimSpace(out) != "")
@ -407,7 +407,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
name := "testvolume"
out, _ := dockerCmd(c, "volume", "create", name)
id := strings.TrimSpace(out)
assert.Assert(c, id, checker.Equals, name)
assert.Equal(c, id, name)
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
out, _ = dockerCmd(c, "create", "-v", "testvolume:"+prefix+slash+"foo", "busybox")
@ -431,13 +431,13 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
// Verify removing the volume after the container is removed works
_, e := dockerCmd(c, "rm", cid)
assert.Assert(c, e, checker.Equals, 0)
assert.Equal(c, e, 0)
_, e = dockerCmd(c, "volume", "rm", "-f", name)
assert.Assert(c, e, checker.Equals, 0)
assert.Equal(c, e, 0)
out, e = dockerCmd(c, "volume", "ls")
assert.Assert(c, e, checker.Equals, 0)
assert.Equal(c, e, 0)
assert.Assert(c, out, checker.Not(checker.Contains), name)
}

View file

@ -16,13 +16,13 @@ var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestNewEntry(c *testing.T) {
entry, err := NewEntry("127.0.0.1:2375")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), checker.Equals, true)
assert.Assert(c, entry.String(), checker.Equals, "127.0.0.1:2375")
assert.Equal(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), true)
assert.Equal(c, entry.String(), "127.0.0.1:2375")
entry, err = NewEntry("[2001:db8:0:f101::2]:2375")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, entry.Equals(&Entry{Host: "2001:db8:0:f101::2", Port: "2375"}), checker.Equals, true)
assert.Assert(c, entry.String(), checker.Equals, "[2001:db8:0:f101::2]:2375")
assert.Equal(c, entry.Equals(&Entry{Host: "2001:db8:0:f101::2", Port: "2375"}), true)
assert.Equal(c, entry.String(), "[2001:db8:0:f101::2]:2375")
_, err = NewEntry("127.0.0.1")
assert.Assert(c, err, checker.NotNil)
@ -30,24 +30,24 @@ func (s *DiscoverySuite) TestNewEntry(c *testing.T) {
func (s *DiscoverySuite) TestParse(c *testing.T) {
scheme, uri := parse("127.0.0.1:2375")
assert.Assert(c, scheme, checker.Equals, "nodes")
assert.Assert(c, uri, checker.Equals, "127.0.0.1:2375")
assert.Equal(c, scheme, "nodes")
assert.Equal(c, uri, "127.0.0.1:2375")
scheme, uri = parse("localhost:2375")
assert.Assert(c, scheme, checker.Equals, "nodes")
assert.Assert(c, uri, checker.Equals, "localhost:2375")
assert.Equal(c, scheme, "nodes")
assert.Equal(c, uri, "localhost:2375")
scheme, uri = parse("scheme://127.0.0.1:2375")
assert.Assert(c, scheme, checker.Equals, "scheme")
assert.Assert(c, uri, checker.Equals, "127.0.0.1:2375")
assert.Equal(c, scheme, "scheme")
assert.Equal(c, uri, "127.0.0.1:2375")
scheme, uri = parse("scheme://localhost:2375")
assert.Assert(c, scheme, checker.Equals, "scheme")
assert.Assert(c, uri, checker.Equals, "localhost:2375")
assert.Equal(c, scheme, "scheme")
assert.Equal(c, uri, "localhost:2375")
scheme, uri = parse("")
assert.Assert(c, scheme, checker.Equals, "nodes")
assert.Assert(c, uri, checker.Equals, "")
assert.Equal(c, scheme, "nodes")
assert.Equal(c, uri, "")
}
func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
@ -62,7 +62,7 @@ func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
&Entry{Host: "127.0.0.2", Port: "2375"},
&Entry{Host: "2001:db8:0:f101::2", Port: "2375"},
}
assert.Assert(c, entries.Equals(expected), checker.Equals, true)
assert.Equal(c, entries.Equals(expected), true)
_, err = CreateEntries([]string{"127.0.0.1", "127.0.0.2"})
assert.Assert(c, err, checker.NotNil)
@ -71,8 +71,8 @@ func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
func (s *DiscoverySuite) TestContainsEntry(c *testing.T) {
entries, err := CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""})
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), checker.Equals, true)
assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), checker.Equals, false)
assert.Equal(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), true)
assert.Equal(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), false)
}
func (s *DiscoverySuite) TestEntriesEquality(c *testing.T) {
@ -116,19 +116,19 @@ func (s *DiscoverySuite) TestEntriesDiff(c *testing.T) {
// Add
added, removed = entries.Diff(Entries{entry2, entry3, entry1})
assert.Assert(c, added, checker.HasLen, 1)
assert.Assert(c, added.Contains(entry3), checker.Equals, true)
assert.Equal(c, added.Contains(entry3), true)
assert.Assert(c, removed, checker.HasLen, 0)
// Remove
added, removed = entries.Diff(Entries{entry2})
assert.Assert(c, added, checker.HasLen, 0)
assert.Assert(c, removed, checker.HasLen, 1)
assert.Assert(c, removed.Contains(entry1), checker.Equals, true)
assert.Equal(c, removed.Contains(entry1), true)
// Add and remove
added, removed = entries.Diff(Entries{entry1, entry3})
assert.Assert(c, added, checker.HasLen, 1)
assert.Assert(c, added.Contains(entry3), checker.Equals, true)
assert.Equal(c, added.Contains(entry3), true)
assert.Assert(c, removed, checker.HasLen, 1)
assert.Assert(c, removed.Contains(entry2), checker.Equals, true)
assert.Equal(c, removed.Contains(entry2), true)
}

View file

@ -20,13 +20,13 @@ var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{}
d.Initialize("/path/to/file", 1000, 0, nil)
assert.Assert(c, d.path, checker.Equals, "/path/to/file")
assert.Equal(c, d.path, "/path/to/file")
}
func (s *DiscoverySuite) TestNew(c *testing.T) {
d, err := discovery.New("file:///path/to/file", 0, 0, nil)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, d.(*Discovery).path, checker.Equals, "/path/to/file")
assert.Equal(c, d.(*Discovery).path, "/path/to/file")
}
func (s *DiscoverySuite) TestContent(c *testing.T) {
@ -36,11 +36,11 @@ func (s *DiscoverySuite) TestContent(c *testing.T) {
`
ips := parseFileContent([]byte(data))
assert.Assert(c, ips, checker.HasLen, 5)
assert.Assert(c, ips[0], checker.Equals, "1.1.1.1:1111")
assert.Assert(c, ips[1], checker.Equals, "1.1.1.2:1111")
assert.Assert(c, ips[2], checker.Equals, "2.2.2.2:2222")
assert.Assert(c, ips[3], checker.Equals, "2.2.2.3:2222")
assert.Assert(c, ips[4], checker.Equals, "2.2.2.4:2222")
assert.Equal(c, ips[0], "1.1.1.1:1111")
assert.Equal(c, ips[1], "1.1.1.2:1111")
assert.Equal(c, ips[2], "2.2.2.2:2222")
assert.Equal(c, ips[3], "2.2.2.3:2222")
assert.Equal(c, ips[4], "2.2.2.4:2222")
}
func (s *DiscoverySuite) TestRegister(c *testing.T) {
@ -59,8 +59,8 @@ func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) {
`
ips := parseFileContent([]byte(data))
assert.Assert(c, ips, checker.HasLen, 2)
assert.Assert(c, "1.1.1.1:1111", checker.Equals, ips[0])
assert.Assert(c, "3.3.3.3:3333", checker.Equals, ips[1])
assert.Equal(c, "1.1.1.1:1111", ips[0])
assert.Equal(c, "3.3.3.3:3333", ips[1])
}
func (s *DiscoverySuite) TestWatch(c *testing.T) {

View file

@ -6,48 +6,48 @@ import (
func (s *DiscoverySuite) TestGeneratorNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1")
assert.Assert(c, len(ips), checker.Equals, 1)
assert.Assert(c, ips[0], checker.Equals, "127.0.0.1")
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], "127.0.0.1")
}
func (s *DiscoverySuite) TestGeneratorWithPortNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1:8080")
assert.Assert(c, len(ips), checker.Equals, 1)
assert.Assert(c, ips[0], checker.Equals, "127.0.0.1:8080")
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], "127.0.0.1:8080")
}
func (s *DiscoverySuite) TestGeneratorMatchFailedNotGenerate(c *testing.T) {
ips := Generate("127.0.0.[1]")
assert.Assert(c, len(ips), checker.Equals, 1)
assert.Assert(c, ips[0], checker.Equals, "127.0.0.[1]")
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], "127.0.0.[1]")
}
func (s *DiscoverySuite) TestGeneratorWithPort(c *testing.T) {
ips := Generate("127.0.0.[1:11]:2375")
assert.Assert(c, len(ips), checker.Equals, 11)
assert.Assert(c, ips[0], checker.Equals, "127.0.0.1:2375")
assert.Assert(c, ips[1], checker.Equals, "127.0.0.2:2375")
assert.Assert(c, ips[2], checker.Equals, "127.0.0.3:2375")
assert.Assert(c, ips[3], checker.Equals, "127.0.0.4:2375")
assert.Assert(c, ips[4], checker.Equals, "127.0.0.5:2375")
assert.Assert(c, ips[5], checker.Equals, "127.0.0.6:2375")
assert.Assert(c, ips[6], checker.Equals, "127.0.0.7:2375")
assert.Assert(c, ips[7], checker.Equals, "127.0.0.8:2375")
assert.Assert(c, ips[8], checker.Equals, "127.0.0.9:2375")
assert.Assert(c, ips[9], checker.Equals, "127.0.0.10:2375")
assert.Assert(c, ips[10], checker.Equals, "127.0.0.11:2375")
assert.Equal(c, len(ips), 11)
assert.Equal(c, ips[0], "127.0.0.1:2375")
assert.Equal(c, ips[1], "127.0.0.2:2375")
assert.Equal(c, ips[2], "127.0.0.3:2375")
assert.Equal(c, ips[3], "127.0.0.4:2375")
assert.Equal(c, ips[4], "127.0.0.5:2375")
assert.Equal(c, ips[5], "127.0.0.6:2375")
assert.Equal(c, ips[6], "127.0.0.7:2375")
assert.Equal(c, ips[7], "127.0.0.8:2375")
assert.Equal(c, ips[8], "127.0.0.9:2375")
assert.Equal(c, ips[9], "127.0.0.10:2375")
assert.Equal(c, ips[10], "127.0.0.11:2375")
}
func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeStart(c *testing.T) {
malformedInput := "127.0.0.[x:11]:2375"
ips := Generate(malformedInput)
assert.Assert(c, len(ips), checker.Equals, 1)
assert.Assert(c, ips[0], checker.Equals, malformedInput)
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], malformedInput)
}
func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *testing.T) {
malformedInput := "127.0.0.[1:x]:2375"
ips := Generate(malformedInput)
assert.Assert(c, len(ips), checker.Equals, 1)
assert.Assert(c, ips[0], checker.Equals, malformedInput)
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], malformedInput)
}

View file

@ -31,8 +31,8 @@ func (ds *DiscoverySuite) TestInitialize(c *testing.T) {
s := d.store.(*FakeStore)
assert.Assert(c, s.Endpoints, checker.HasLen, 1)
assert.Assert(c, s.Endpoints[0], checker.Equals, "127.0.0.1")
assert.Assert(c, d.path, checker.Equals, defaultDiscoveryPath)
assert.Equal(c, s.Endpoints[0], "127.0.0.1")
assert.Equal(c, d.path, defaultDiscoveryPath)
storeMock = &FakeStore{
Endpoints: []string{"127.0.0.1:1234"},
@ -43,8 +43,8 @@ func (ds *DiscoverySuite) TestInitialize(c *testing.T) {
s = d.store.(*FakeStore)
assert.Assert(c, s.Endpoints, checker.HasLen, 1)
assert.Assert(c, s.Endpoints[0], checker.Equals, "127.0.0.1:1234")
assert.Assert(c, d.path, checker.Equals, "path/"+defaultDiscoveryPath)
assert.Equal(c, s.Endpoints[0], "127.0.0.1:1234")
assert.Equal(c, d.path, "path/"+defaultDiscoveryPath)
storeMock = &FakeStore{
Endpoints: []string{"127.0.0.1:1234", "127.0.0.2:1234", "127.0.0.3:1234"},
@ -55,11 +55,11 @@ func (ds *DiscoverySuite) TestInitialize(c *testing.T) {
s = d.store.(*FakeStore)
assert.Assert(c, s.Endpoints, checker.HasLen, 3)
assert.Assert(c, s.Endpoints[0], checker.Equals, "127.0.0.1:1234")
assert.Assert(c, s.Endpoints[1], checker.Equals, "127.0.0.2:1234")
assert.Assert(c, s.Endpoints[2], checker.Equals, "127.0.0.3:1234")
assert.Equal(c, s.Endpoints[0], "127.0.0.1:1234")
assert.Equal(c, s.Endpoints[1], "127.0.0.2:1234")
assert.Equal(c, s.Endpoints[2], "127.0.0.3:1234")
assert.Assert(c, d.path, checker.Equals, "path/"+defaultDiscoveryPath)
assert.Equal(c, d.path, "path/"+defaultDiscoveryPath)
}
// Extremely limited mock store so we can test initialization

View file

@ -18,20 +18,20 @@ var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{}
d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)
assert.Assert(c, len(d.entries), checker.Equals, 2)
assert.Assert(c, d.entries[0].String(), checker.Equals, "1.1.1.1:1111")
assert.Assert(c, d.entries[1].String(), checker.Equals, "2.2.2.2:2222")
assert.Equal(c, len(d.entries), 2)
assert.Equal(c, d.entries[0].String(), "1.1.1.1:1111")
assert.Equal(c, d.entries[1].String(), "2.2.2.2:2222")
}
func (s *DiscoverySuite) TestInitializeWithPattern(c *testing.T) {
d := &Discovery{}
d.Initialize("1.1.1.[1:2]:1111,2.2.2.[2:4]:2222", 0, 0, nil)
assert.Assert(c, len(d.entries), checker.Equals, 5)
assert.Assert(c, d.entries[0].String(), checker.Equals, "1.1.1.1:1111")
assert.Assert(c, d.entries[1].String(), checker.Equals, "1.1.1.2:1111")
assert.Assert(c, d.entries[2].String(), checker.Equals, "2.2.2.2:2222")
assert.Assert(c, d.entries[3].String(), checker.Equals, "2.2.2.3:2222")
assert.Assert(c, d.entries[4].String(), checker.Equals, "2.2.2.4:2222")
assert.Equal(c, len(d.entries), 5)
assert.Equal(c, d.entries[0].String(), "1.1.1.1:1111")
assert.Equal(c, d.entries[1].String(), "1.1.1.2:1111")
assert.Equal(c, d.entries[2].String(), "2.2.2.2:2222")
assert.Equal(c, d.entries[3].String(), "2.2.2.3:2222")
assert.Equal(c, d.entries[4].String(), "2.2.2.4:2222")
}
func (s *DiscoverySuite) TestWatch(c *testing.T) {
@ -42,7 +42,7 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) {
&discovery.Entry{Host: "2.2.2.2", Port: "2222"},
}
ch, _ := d.Watch(nil)
assert.Assert(c, expected.Equals(<-ch), checker.Equals, true)
assert.Equal(c, expected.Equals(<-ch), true)
}
func (s *DiscoverySuite) TestRegister(c *testing.T) {