From 230f7bcc02569dfa916401ac6259643be8bb84f7 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Mon, 9 Sep 2019 21:05:56 +0000 Subject: [PATCH] rm-gocheck: normalize to use checker sed -E -i 's#\bcheck\.(Equals|DeepEquals|HasLen|IsNil|Matches|Not|NotNil)\b#checker.\1#g' \ -- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_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_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_inspect_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_utils_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/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go" Signed-off-by: Tibor Vass --- integration-cli/docker_api_containers_test.go | 12 +-- integration-cli/docker_cli_attach_test.go | 8 +- .../docker_cli_attach_unix_test.go | 4 +- integration-cli/docker_cli_build_test.go | 16 ++-- integration-cli/docker_cli_build_unix_test.go | 12 +-- integration-cli/docker_cli_by_digest_test.go | 10 +-- integration-cli/docker_cli_create_test.go | 20 ++--- integration-cli/docker_cli_daemon_test.go | 84 +++++++++---------- ...er_cli_external_volume_driver_unix_test.go | 14 ++-- integration-cli/docker_cli_health_test.go | 2 +- integration-cli/docker_cli_images_test.go | 6 +- integration-cli/docker_cli_inspect_test.go | 16 ++-- integration-cli/docker_cli_netmode_test.go | 2 +- .../docker_cli_network_unix_test.go | 68 +++++++-------- integration-cli/docker_cli_port_test.go | 6 +- integration-cli/docker_cli_run_test.go | 72 ++++++++-------- integration-cli/docker_cli_run_unix_test.go | 24 +++--- integration-cli/docker_cli_save_load_test.go | 4 +- .../docker_cli_service_health_test.go | 2 +- integration-cli/docker_cli_swarm_test.go | 2 +- integration-cli/docker_cli_volume_test.go | 52 ++++++------ integration-cli/docker_utils_test.go | 8 +- pkg/discovery/discovery_test.go | 80 +++++++++--------- pkg/discovery/file/file_test.go | 50 +++++------ pkg/discovery/generator_test.go | 44 +++++----- pkg/discovery/kv/kv_test.go | 42 +++++----- pkg/discovery/memory/memory_test.go | 12 +-- pkg/discovery/nodes/nodes_test.go | 22 ++--- 28 files changed, 347 insertions(+), 347 deletions(-) diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 50f3b44d55..236a39b21b 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -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, check.Equals, defaultSHMSize) + assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, 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, check.Equals, int64(67108864)) + assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, 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, check.Equals, int64(1073741824)) + assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, int64(1073741824)) out, _ := dockerCmd(c, "start", "-i", containerJSON.ID) shmRegex := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=1048576k`) @@ -1542,9 +1542,9 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted( assert.NilError(c, err) if versions.LessThan(testEnv.DaemonAPIVersion(), "1.31") { - assert.Assert(c, *containerJSON.HostConfig.MemorySwappiness, check.Equals, int64(-1)) + assert.Assert(c, *containerJSON.HostConfig.MemorySwappiness, checker.Equals, int64(-1)) } else { - assert.Assert(c, containerJSON.HostConfig.MemorySwappiness, check.IsNil) + assert.Assert(c, containerJSON.HostConfig.MemorySwappiness, checker.IsNil) } } @@ -1614,7 +1614,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) { err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{}) assert.NilError(c, err) - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) type b struct { stats types.ContainerStats diff --git a/integration-cli/docker_cli_attach_test.go b/integration-cli/docker_cli_attach_test.go index ac1886926c..7a787c6409 100644 --- a/integration-cli/docker_cli_attach_test.go +++ b/integration-cli/docker_cli_attach_test.go @@ -147,7 +147,7 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) { stdout, err := cmd.StdoutPipe() assert.NilError(c, err) defer stdout.Close() - assert.Assert(c, cmd.Start(), check.IsNil) + assert.Assert(c, cmd.Start(), checker.IsNil) defer func() { cmd.Process.Kill() cmd.Wait() @@ -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), check.Equals, "hello") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello") - assert.Assert(c, stdin.Close(), check.IsNil) + 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, check.Equals, "true") + assert.Assert(c, running, checker.Equals, "true") } func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) { diff --git a/integration-cli/docker_cli_attach_unix_test.go b/integration-cli/docker_cli_attach_unix_test.go index b8d3f8ed76..64858adc66 100644 --- a/integration-cli/docker_cli_attach_unix_test.go +++ b/integration-cli/docker_cli_attach_unix_test.go @@ -51,7 +51,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) { case err := <-errChan: tty.Close() out, _ := ioutil.ReadAll(pty) - assert.Assert(c, err, check.IsNil, check.Commentf("out: %v", string(out))) + assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", string(out))) case <-time.After(attachWait): c.Fatal("timed out without attach returning") } @@ -74,7 +74,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) { close(cmdExit) }() - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) cpty.Write([]byte{16}) time.Sleep(100 * time.Millisecond) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 01cb499356..885b994169 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -4373,7 +4373,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *testing.T) { ) res := inspectField(c, imgName, "Config.WorkingDir") - assert.Assert(c, filepath.ToSlash(res), check.Equals, filepath.ToSlash(wdVal)) + assert.Assert(c, filepath.ToSlash(res), checker.Equals, 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, check.Equals, id2) + assert.Assert(c, id1, checker.Equals, id2) } // #17290 @@ -5572,7 +5572,7 @@ func (s *DockerSuite) TestBuildNetContainer(c *testing.T) { `)) host, _ := dockerCmd(c, "run", "testbuildnetcontainer", "cat", "/otherhost") - assert.Assert(c, strings.TrimSpace(host), check.Equals, "foobar") + assert.Assert(c, strings.TrimSpace(host), checker.Equals, "foobar") } func (s *DockerSuite) TestBuildWithExtraHost(c *testing.T) { @@ -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), check.Equals, "abc") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "abc") out = cli.DockerCmd(c, "run", "build2", "cat", "foo").Combined() - assert.Assert(c, strings.TrimSpace(out), check.Equals, "def") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "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), check.Equals, "abc") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "abc") out = cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\foo").Combined() - assert.Assert(c, strings.TrimSpace(out), check.Equals, "def") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "def") } func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) { @@ -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), check.Equals, true) + assert.Assert(c, os.IsNotExist(err), checker.Equals, true) } diff --git a/integration-cli/docker_cli_build_unix_test.go b/integration-cli/docker_cli_build_unix_test.go index 7cb6819be4..5e31321245 100644 --- a/integration-cli/docker_cli_build_unix_test.go +++ b/integration-cli/docker_cli_build_unix_test.go @@ -76,12 +76,12 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) { err = json.Unmarshal([]byte(cfg), &c2) assert.Assert(c, err, checker.IsNil, check.Commentf(cfg)) - assert.Assert(c, c2.Memory, check.Not(checker.Equals), int64(64*1024*1024), check.Commentf("resource leaked from build for Memory")) - assert.Assert(c, c2.MemorySwap, check.Not(checker.Equals), int64(-1), check.Commentf("resource leaked from build for MemorySwap")) - assert.Assert(c, c2.CpusetCpus, check.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetCpus")) - assert.Assert(c, c2.CpusetMems, check.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetMems")) - assert.Assert(c, c2.CPUShares, check.Not(checker.Equals), int64(100), check.Commentf("resource leaked from build for CPUShares")) - assert.Assert(c, c2.CPUQuota, check.Not(checker.Equals), int64(8000), check.Commentf("resource leaked from build for CPUQuota")) + assert.Assert(c, c2.Memory, checker.Not(checker.Equals), int64(64*1024*1024), check.Commentf("resource leaked from build for Memory")) + assert.Assert(c, c2.MemorySwap, checker.Not(checker.Equals), int64(-1), check.Commentf("resource leaked from build for MemorySwap")) + assert.Assert(c, c2.CpusetCpus, checker.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetCpus")) + assert.Assert(c, c2.CpusetMems, checker.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetMems")) + assert.Assert(c, c2.CPUShares, checker.Not(checker.Equals), int64(100), check.Commentf("resource leaked from build for CPUShares")) + assert.Assert(c, c2.CPUQuota, checker.Not(checker.Equals), int64(8000), check.Commentf("resource leaked from build for CPUQuota")) assert.Assert(c, c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits")) } diff --git a/integration-cli/docker_cli_by_digest_test.go b/integration-cli/docker_cli_by_digest_test.go index e2b32a703e..7792659977 100644 --- a/integration-cli/docker_cli_by_digest_test.go +++ b/integration-cli/docker_cli_by_digest_test.go @@ -389,7 +389,7 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) { func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) { digest, err := setupImage(c) - assert.Assert(c, err, check.IsNil, check.Commentf("error setting up image")) + assert.Assert(c, err, checker.IsNil, check.Commentf("error setting up image")) imageReference := fmt.Sprintf("%s@%s", repoName, digest) @@ -556,7 +556,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) { // Pull from the registry using the @ reference. imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest) out, exitStatus, _ := dockerCmdWithError("pull", imageReference) - assert.Assert(c, exitStatus, checker.Not(check.Equals), 0) + assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0) expectedErrorMsg := fmt.Sprintf("manifest verification failed for digest %s", manifestDigest) assert.Assert(c, is.Contains(out, expectedErrorMsg)) @@ -598,7 +598,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing // Pull from the registry using the @ reference. imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest) out, exitStatus, _ := dockerCmdWithError("pull", imageReference) - assert.Assert(c, exitStatus, checker.Not(check.Equals), 0) + assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0) expectedErrorMsg := fmt.Sprintf("image verification failed for digest %s", manifestDigest) assert.Assert(c, out, checker.Contains, expectedErrorMsg) @@ -641,7 +641,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) { // Pull from the registry using the @ reference. imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest) out, exitStatus, _ := dockerCmdWithError("pull", imageReference) - assert.Assert(c, exitStatus, checker.Not(check.Equals), 0, check.Commentf("expected a non-zero exit status")) + assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0, check.Commentf("expected a non-zero exit status")) expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest) assert.Assert(c, out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out)) @@ -684,7 +684,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) // Pull from the registry using the @ reference. imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest) out, exitStatus, _ := dockerCmdWithError("pull", imageReference) - assert.Assert(c, exitStatus, checker.Not(check.Equals), 0, check.Commentf("expected a non-zero exit status")) + assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0, check.Commentf("expected a non-zero exit status")) expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest) assert.Assert(c, out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out)) diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go index 5eaea7418d..d2e570b1e4 100644 --- a/integration-cli/docker_cli_create_test.go +++ b/integration-cli/docker_cli_create_test.go @@ -37,7 +37,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) { } err := json.Unmarshal([]byte(out), &containers) - assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err)) assert.Equal(c, len(containers), 1) cont := containers[0] @@ -96,11 +96,11 @@ func (s *DockerSuite) TestCreateHostConfig(c *testing.T) { } err := json.Unmarshal([]byte(out), &containers) - assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err)) assert.Equal(c, len(containers), 1) cont := containers[0] - assert.Assert(c, cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none")) + assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none")) assert.Assert(c, cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false")) } @@ -117,12 +117,12 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) { } } err := json.Unmarshal([]byte(out), &containers) - assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err)) assert.Equal(c, len(containers), 1) cont := containers[0] - assert.Assert(c, cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none")) + assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none")) assert.Assert(c, cont.HostConfig.PortBindings, checker.HasLen, 4, check.Commentf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings))) for k, v := range cont.HostConfig.PortBindings { @@ -147,11 +147,11 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) { } err := json.Unmarshal([]byte(out), &containers) - assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err)) assert.Equal(c, len(containers), 1) cont := containers[0] - assert.Assert(c, cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none")) + assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none")) assert.Assert(c, cont.HostConfig.PortBindings, checker.HasLen, 65535) for k, v := range cont.HostConfig.PortBindings { @@ -179,7 +179,7 @@ func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) { dockerCmd(c, "create", "--name", name, "-v", prefix+slash+"foo", "busybox") dir, err := inspectMountSourceField(name, prefix+slash+"foo") - assert.Assert(c, err, check.IsNil, check.Commentf("Error getting volume host path: %q", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Error getting volume host path: %q", err)) if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) { c.Fatalf("Volume was not created") @@ -354,9 +354,9 @@ exec "$@"`, out := cli.DockerCmd(c, "create", "--entrypoint=", name, "echo", "foo").Combined() id := strings.TrimSpace(out) - assert.Assert(c, id, check.Not(check.Equals), "") + assert.Assert(c, id, checker.Not(checker.Equals), "") out = cli.DockerCmd(c, "start", "-a", id).Combined() - assert.Assert(c, strings.TrimSpace(out), check.Equals, "foo") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "foo") } // #22471 diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index f99107e81d..0bb8cfd758 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -130,13 +130,13 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *testing.T) { var format string for name, shouldRun := range m { out, err := s.d.Cmd("ps") - assert.Assert(c, err, check.IsNil, check.Commentf("run ps: %v", out)) + assert.Assert(c, err, checker.IsNil, check.Commentf("run ps: %v", out)) if shouldRun { format = "%scontainer %q is not running" } else { format = "%scontainer %q is running" } - assert.Assert(c, strings.Contains(out, name), check.Equals, shouldRun, check.Commentf(format, prefix, name)) + assert.Assert(c, strings.Contains(out, name), checker.Equals, shouldRun, check.Commentf(format, prefix, name)) } } @@ -216,7 +216,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *testing.T) { if newBasesizeBytes < oldBasesizeBytes { err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) - assert.Assert(c, err, check.NotNil, check.Commentf("daemon should not have started as new base device size is less than existing base device size: %v", err)) + assert.Assert(c, err, checker.NotNil, check.Commentf("daemon should not have started as new base device size is less than existing base device size: %v", err)) // 'err != nil' is expected behaviour, no new daemon started, // so no need to stop daemon. if err != nil { @@ -240,12 +240,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T) } err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) - assert.Assert(c, err, check.IsNil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err)) basesizeAfterRestart := getBaseDeviceSize(c, s.d) newBasesize, err := convertBasesize(newBasesizeBytes) - assert.Assert(c, err, check.IsNil, check.Commentf("Error in converting base device size: %v", err)) - assert.Assert(c, newBasesize, check.Equals, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set")) + 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")) s.d.Stop(c) } @@ -477,7 +477,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *testing.T) { } func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *testing.T) { - assert.Assert(c, s.d.StartWithError("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level")) + assert.Assert(c, s.d.StartWithError("--log-level=bogus"), checker.NotNil, check.Commentf("Daemon shouldn't start with wrong log level")) } func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *testing.T) { @@ -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), check.Equals, true, check.Commentf("Container IP-Address must be in the same subnet range : %s", containerIP)) + assert.Assert(c, bridgeIPNet.Contains(ip), checker.Equals, 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), check.Equals, true, check.Commentf("Implicit default gateway should be bridge IP %s, but default route was '%s'", bridgeIP, strings.TrimSpace(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))) 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), check.Equals, true, check.Commentf("Explicit default gateway should be %s, but default route was '%s'", gatewayIP, strings.TrimSpace(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))) deleteInterface(c, defaultNetworkBridge) } @@ -844,8 +844,8 @@ func (s *DockerDaemonSuite) TestDaemonIP(c *testing.T) { defer d.Restart(c) out, err := d.Cmd("run", "-d", "-p", "8000:8000", "busybox", "top") - assert.Assert(c, err, check.NotNil, check.Commentf("Running a container must fail with an invalid --ip option")) - assert.Assert(c, strings.Contains(out, "Error starting userland proxy"), check.Equals, true) + 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) 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, check.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined())) + assert.Assert(c, matched, checker.Equals, 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, check.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined())) + assert.Assert(c, matched, checker.Equals, 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, check.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined())) + assert.Assert(c, matched, checker.Equals, 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) @@ -1136,7 +1136,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *testing.T) { assert.NilError(c, err, out) out, err = s.d.Cmd("logs", "test") - assert.Assert(c, err, check.NotNil, check.Commentf("Logs should fail with 'none' driver")) + assert.Assert(c, err, checker.NotNil, check.Commentf("Logs should fail with 'none' driver")) expected := `configured logging driver does not support reading` assert.Assert(c, strings.Contains(out, expected)) } @@ -1151,8 +1151,8 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *te build.WithoutCache, ) comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error) - assert.Assert(c, result.Error, check.IsNil, comment) - assert.Assert(c, result.ExitCode, check.Equals, 0, comment) + assert.Assert(c, result.Error, checker.IsNil, comment) + assert.Assert(c, result.ExitCode, checker.Equals, 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), check.Equals, id[:12]) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, id[:12]) } func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *testing.T) { @@ -1630,7 +1630,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *testing.T) { s.d.Restart(c) out, err = s.d.Cmd("volume", "rm", "test") - assert.Assert(c, err, check.NotNil, check.Commentf("should not be able to remove in use volume after daemon restart")) + assert.Assert(c, err, checker.NotNil, check.Commentf("should not be able to remove in use volume after daemon restart")) assert.Assert(c, out, checker.Contains, "in use") } @@ -1648,7 +1648,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *testing.T) { // FIXME(vdemeester) should be a unit test func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *testing.T) { d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) - assert.Assert(c, d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil) + assert.Assert(c, d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), checker.NotNil) expected := "syslog-address should be in form proto://address" icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success) } @@ -1656,7 +1656,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *testing.T) { // FIXME(vdemeester) should be a unit test func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *testing.T) { d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) - assert.Assert(c, d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil) + assert.Assert(c, d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), checker.NotNil) expected := "invalid fluentd-address corrupted:c: " icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success) } @@ -1749,9 +1749,9 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T break } ip, err := s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.IPAddress}}'", contName) - assert.Assert(c, err, check.IsNil, check.Commentf("%s", ip)) + assert.Assert(c, err, checker.IsNil, check.Commentf("%s", ip)) - assert.Assert(c, ip, check.Not(check.Equals), bridgeIP) + assert.Assert(c, ip, checker.Not(checker.Equals), bridgeIP) cont++ } } @@ -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"), check.Equals, true, check.Commentf("%s", out)) + assert.Assert(c, strings.Contains(out, "1 packets transmitted, 1 packets received"), checker.Equals, true, check.Commentf("%s", out)) } func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *testing.T) { @@ -1999,14 +1999,14 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) { id := strings.TrimSpace(out) // kill the daemon - assert.Assert(c, s.d.Kill(), check.IsNil) + assert.Assert(c, s.d.Kill(), checker.IsNil) // Check if there are mounts with container id visible from the host. // If not, those mounts exist in container's own mount ns, and so // the following check for mounts being cleared is pointless. skipMountCheck := false mountOut, err := ioutil.ReadFile("/proc/self/mountinfo") - assert.Assert(c, err, check.IsNil, check.Commentf("Output: %s", mountOut)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", mountOut)) if !strings.Contains(string(mountOut), id) { skipMountCheck = true } @@ -2031,9 +2031,9 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) { } // Now, container mounts should be gone. mountOut, err = ioutil.ReadFile("/proc/self/mountinfo") - assert.Assert(c, err, check.IsNil, check.Commentf("Output: %s", mountOut)) + 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), check.Equals, false, comment) + assert.Assert(c, strings.Contains(string(mountOut), id), checker.Equals, false, comment) } // TestDaemonRestartWithUnpausedRunningContainer requires live restore of running containers. @@ -2112,12 +2112,12 @@ func (s *DockerDaemonSuite) TestRunLinksChanged(c *testing.T) { assert.NilError(c, err, out) out, err = s.d.Cmd("start", "-a", "test2") assert.ErrorContains(c, err, "", out) - assert.Assert(c, out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received") + assert.Assert(c, out, checker.Not(checker.Contains), "1 packets transmitted, 1 packets received") s.d.Restart(c) out, err = s.d.Cmd("start", "-a", "test2") assert.ErrorContains(c, err, "", out) - assert.Assert(c, out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received") + assert.Assert(c, out, checker.Not(checker.Contains), "1 packets transmitted, 1 packets received") } func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) { @@ -2166,8 +2166,8 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) { s.d.Stop(c) // Wait for io.Copy() before checking output <-done - assert.Assert(c, b.String(), check.Not(check.Equals), "") - assert.Assert(c, b.String(), check.Not(checker.Contains), infoLog) + assert.Assert(c, b.String(), checker.Not(checker.Equals), "") + assert.Assert(c, b.String(), checker.Not(checker.Contains), infoLog) } func (s *DockerDaemonSuite) TestDaemonDebugLog(c *testing.T) { @@ -2369,8 +2369,8 @@ func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *testing.T) build.WithoutCache, ) comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error) - assert.Assert(c, result.Error, check.IsNil, comment) - assert.Assert(c, result.ExitCode, check.Equals, 0, comment) + assert.Assert(c, result.Error, checker.IsNil, comment) + assert.Assert(c, result.ExitCode, checker.Equals, 0, comment) } // Test case for #21976 @@ -2727,18 +2727,18 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) { // Wait for shell command to be completed _, err = s.d.Cmd("exec", "top", "sh", "-c", `for i in $(seq 1 5); do if [ -e /adduser_end ]; then rm -f /adduser_end && break; else sleep 1 && false; fi; done`) - assert.Assert(c, err, check.IsNil, check.Commentf("Timeout waiting for shell command to be completed")) + assert.Assert(c, err, checker.IsNil, check.Commentf("Timeout waiting for shell command to be completed")) out1, err := s.d.Cmd("exec", "-u", "test", "top", "id") // uid=100(test) gid=101(test) groups=101(test) - assert.Assert(c, err, check.IsNil, check.Commentf("Output: %s", out1)) + assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out1)) // restart daemon. s.d.Restart(c, "--live-restore") out2, err := s.d.Cmd("exec", "-u", "test", "top", "id") - assert.Assert(c, err, check.IsNil, check.Commentf("Output: %s", out2)) - assert.Assert(c, out2, check.Equals, out1, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2)) + 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)) 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), check.Equals, fmt.Sprintf("%v", size)) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, 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), check.Equals, fmt.Sprintf("%v", size)) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, 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), check.Equals, fmt.Sprintf("%v", size)) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%v", size)) } func testDaemonStartIpcMode(c *testing.T, from, mode string, valid bool) { diff --git a/integration-cli/docker_cli_external_volume_driver_unix_test.go b/integration-cli/docker_cli_external_volume_driver_unix_test.go index a391c62eac..4670d79c28 100644 --- a/integration-cli/docker_cli_external_volume_driver_unix_test.go +++ b/integration-cli/docker_cli_external_volume_driver_unix_test.go @@ -287,7 +287,7 @@ func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing dockerCmd(c, "volume", "create", "test") out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName) - assert.Assert(c, err, check.NotNil, check.Commentf("volume create exception name already in use with another driver")) + assert.Assert(c, err, checker.NotNil, check.Commentf("volume create exception name already in use with another driver")) assert.Assert(c, out, checker.Contains, "must be unique") out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test") @@ -463,21 +463,21 @@ 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), check.Equals, 2, check.Commentf("\n%s", out)) + assert.Assert(c, len(ls), checker.Equals, 2, check.Commentf("\n%s", out)) vol := strings.Fields(ls[len(ls)-1]) - assert.Assert(c, len(vol), check.Equals, 2, check.Commentf("%v", vol)) - assert.Assert(c, vol[0], check.Equals, volumePluginName) - assert.Assert(c, vol[1], check.Equals, "abc3") + 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.Assert(c, s.ec.lists, check.Equals, 1) + assert.Assert(c, s.ec.lists, checker.Equals, 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, check.Equals, 1) + assert.Assert(c, s.ec.gets, checker.Equals, 1) dockerCmd(c, "volume", "create", "test", "-d", volumePluginName) out, _ = dockerCmd(c, "volume", "inspect", "test") diff --git a/integration-cli/docker_cli_health_test.go b/integration-cli/docker_cli_health_test.go index 4f1df41c81..1b8d136904 100644 --- a/integration-cli/docker_cli_health_test.go +++ b/integration-cli/docker_cli_health_test.go @@ -113,7 +113,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, check.IsNil) + assert.Assert(c, err, checker.IsNil) assert.Assert(c, fails >= 3, checker.Equals, true) dockerCmd(c, "rm", "-f", "fatal_healthcheck") diff --git a/integration-cli/docker_cli_images_test.go b/integration-cli/docker_cli_images_test.go index 011388d792..2052ed7b6a 100644 --- a/integration-cli/docker_cli_images_test.go +++ b/integration-cli/docker_cli_images_test.go @@ -92,9 +92,9 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) { out, _ := dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match") out = strings.TrimSpace(out) - assert.Assert(c, out, check.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID)) - assert.Assert(c, out, check.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID)) - assert.Assert(c, out, check.Not(check.Matches), fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID)) + assert.Assert(c, out, checker.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID)) + assert.Assert(c, out, checker.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID)) + assert.Assert(c, out, checker.Not(checker.Matches), fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID)) out, _ = dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match=me too") out = strings.TrimSpace(out) diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go index 589fc50612..b9189c572b 100644 --- a/integration-cli/docker_cli_inspect_test.go +++ b/integration-cli/docker_cli_inspect_test.go @@ -223,7 +223,7 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) { assert.NilError(c, err) // check that there is only one mountpoint - assert.Assert(c, mp, check.HasLen, 1) + assert.Assert(c, mp, checker.HasLen, 1) m := mp[0] @@ -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), check.Equals, ",", check.Commentf("Expected not to display size info: %s", out)) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, ",", check.Commentf("Expected not to display size info: %s", out)) } func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) { @@ -314,8 +314,8 @@ func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) { out, _ := dockerCmd(c, "inspect", "-s", "--type=container", formatStr, "busybox") sz := strings.Split(out, ",") - assert.Assert(c, strings.TrimSpace(sz[0]), check.Not(check.Equals), "") - assert.Assert(c, strings.TrimSpace(sz[1]), check.Not(check.Equals), "") + assert.Assert(c, strings.TrimSpace(sz[0]), checker.Not(checker.Equals), "") + assert.Assert(c, strings.TrimSpace(sz[1]), checker.Not(checker.Equals), "") } func (s *DockerSuite) TestInspectTemplateError(c *testing.T) { @@ -324,11 +324,11 @@ func (s *DockerSuite) TestInspectTemplateError(c *testing.T) { runSleepingContainer(c, "--name=container1", "-d") out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "container1") - assert.Assert(c, err, check.Not(check.IsNil)) + assert.Assert(c, err, checker.Not(checker.IsNil)) assert.Assert(c, out, checker.Contains, "Template parsing error") out, _, err = dockerCmdWithError("inspect", "--type=image", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox") - assert.Assert(c, err, check.Not(check.IsNil)) + assert.Assert(c, err, checker.Not(checker.IsNil)) assert.Assert(c, out, checker.Contains, "Template parsing error") } @@ -356,7 +356,7 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) { runSleepingContainer(c, "--name=busybox2", "-d") result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing") - assert.Assert(c, result.Error, checker.Not(check.IsNil)) + assert.Assert(c, result.Error, checker.Not(checker.IsNil)) assert.Assert(c, result.Stdout(), checker.Contains, "busybox1") assert.Assert(c, result.Stdout(), checker.Contains, "busybox2") assert.Assert(c, result.Stderr(), checker.Contains, "Error: No such container: missing") @@ -364,7 +364,7 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) { // test inspect would not fast fail result = dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "missing", "busybox1", "busybox2") - assert.Assert(c, result.Error, checker.Not(check.IsNil)) + assert.Assert(c, result.Error, checker.Not(checker.IsNil)) assert.Assert(c, result.Stdout(), checker.Contains, "busybox1") assert.Assert(c, result.Stdout(), checker.Contains, "busybox2") assert.Assert(c, result.Stderr(), checker.Contains, "Error: No such container: missing") diff --git a/integration-cli/docker_cli_netmode_test.go b/integration-cli/docker_cli_netmode_test.go index a26acf2da2..c04de308aa 100644 --- a/integration-cli/docker_cli_netmode_test.go +++ b/integration-cli/docker_cli_netmode_test.go @@ -19,7 +19,7 @@ const stringCheckPS = "PID USER" // stop the tests. func dockerCmdWithFail(c *testing.T, args ...string) (string, int) { out, status, err := dockerCmdWithError(args...) - assert.Assert(c, err, check.NotNil, check.Commentf("%v", out)) + assert.Assert(c, err, checker.NotNil, check.Commentf("%v", out)) return out, status } diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 85b4cb8c31..da29fd4db9 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -64,7 +64,7 @@ func (s *DockerNetworkSuite) TearDownTest(c *testing.T) { func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) { mux := http.NewServeMux() s.server = httptest.NewServer(mux) - assert.Assert(c, s.server, check.NotNil, check.Commentf("Failed to start an HTTP Server")) + assert.Assert(c, s.server, checker.NotNil, check.Commentf("Failed to start an HTTP Server")) setupRemoteNetworkDrivers(c, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver) } @@ -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), check.Equals, 1, check.Commentf("%s\n", out)) + assert.Assert(c, len(outArr), checker.Equals, 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), check.Equals, testValue) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, 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), check.Equals, "host") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "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), check.Equals, networkID) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, networkID) out, _ = dockerCmd(c, "network", "inspect", "--format={{ .ID }}", "test2") - assert.Assert(c, strings.TrimSpace(out), check.Equals, networkID) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, networkID) } func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *testing.T) { @@ -505,7 +505,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *testing.T) { }() out, _ := dockerCmd(c, "run", "-d", "--name", "testNetInspect1", "--net", "brNetForInspect", "busybox", "top") - assert.Assert(c, waitRun("testNetInspect1"), check.IsNil) + assert.Assert(c, waitRun("testNetInspect1"), checker.IsNil) containerID := strings.TrimSpace(out) defer func() { // we don't stop container by name, because we'll rename it later @@ -546,7 +546,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) { // run a container out, _ := dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top") - assert.Assert(c, waitRun("test"), check.IsNil) + assert.Assert(c, waitRun("test"), checker.IsNil) containerID := strings.TrimSpace(out) // connect the container to the test network @@ -570,7 +570,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) { // run another container out, _ = dockerCmd(c, "run", "-d", "--net", "test", "--name", "test2", "busybox", "top") - assert.Assert(c, waitRun("test2"), check.IsNil) + assert.Assert(c, waitRun("test2"), checker.IsNil) containerID = strings.TrimSpace(out) nr = getNwResource(c, "test") @@ -1138,7 +1138,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *testing.T) { dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") - assert.Assert(c, waitRun("container1"), check.IsNil) + assert.Assert(c, waitRun("container1"), checker.IsNil) dockerCmd(c, "network", "disconnect", "bridge", "container1") out, _, err := dockerCmdWithError("network", "connect", "host", "container1") assert.ErrorContains(c, err, "", out) @@ -1147,7 +1147,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *t func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) { dockerCmd(c, "run", "-d", "--name", "container1", "--net=host", "busybox", "top") - assert.Assert(c, waitRun("container1"), check.IsNil) + assert.Assert(c, waitRun("container1"), checker.IsNil) out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1") assert.Assert(c, err, checker.NotNil, check.Commentf("Should err out disconnect from host")) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error()) @@ -1157,7 +1157,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing. testRequires(c, NotArm) dockerCmd(c, "network", "create", "test1") dockerCmd(c, "run", "-d", "--name", "c1", "-p", "5000:5000", "busybox", "top") - assert.Assert(c, waitRun("c1"), check.IsNil) + assert.Assert(c, waitRun("c1"), checker.IsNil) dockerCmd(c, "network", "connect", "test1", "c1") } @@ -1181,7 +1181,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c dockerCmd(c, "network", "create", "ccc") dockerCmd(c, "run", "-d", "--name", cnt, "-p", "9000:90", "-p", "70", "busybox", "top") - assert.Assert(c, waitRun(cnt), check.IsNil) + assert.Assert(c, waitRun(cnt), checker.IsNil) curPortMap, _ := dockerCmd(c, "port", cnt, "70") curExplPortMap, _ := dockerCmd(c, "port", cnt, "90") @@ -1211,7 +1211,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *testing.T) { macAddress := "02:42:ac:11:00:02" dockerCmd(c, "network", "create", "mynetwork") dockerCmd(c, "run", "--name=test", "-d", "--mac-address", macAddress, "busybox", "top") - assert.Assert(c, waitRun("test"), check.IsNil) + assert.Assert(c, waitRun("test"), checker.IsNil) mac1 := inspectField(c, "test", "NetworkSettings.Networks.bridge.MacAddress") assert.Assert(c, strings.TrimSpace(mac1), checker.Equals, macAddress) dockerCmd(c, "network", "connect", "mynetwork", "test") @@ -1296,7 +1296,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) { // run a container on first network specifying the ip addresses dockerCmd(c, "run", "-d", "--name", "c0", "--net=n0", "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top") - assert.Assert(c, waitRun("c0"), check.IsNil) + assert.Assert(c, waitRun("c0"), checker.IsNil) verifyIPAddressConfig(c, "c0", "n0", "172.28.99.88", "2001:db8:1234::9988") verifyIPAddresses(c, "c0", "n0", "172.28.99.88", "2001:db8:1234::9988") @@ -1336,7 +1336,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer // start the container, verify config has not changed and ip addresses are assigned dockerCmd(c, "start", "c0") - assert.Assert(c, waitRun("c0"), check.IsNil) + assert.Assert(c, waitRun("c0"), checker.IsNil) verifyIPAddressConfig(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544") verifyIPAddresses(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544") @@ -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), check.Equals, ipv4) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv4) } if ipv6 != "" { out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv6Address", nwname)) - assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv6) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, 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), check.Equals, ipv4) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv4) out = inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.GlobalIPv6Address", nwname)) - assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv6) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, ipv6) } func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) { @@ -1406,13 +1406,13 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) { // run two containers with link-local ip on the test network dockerCmd(c, "run", "-d", "--name", "c0", "--net=n0", "--link-local-ip", "169.254.7.7", "--link-local-ip", "fe80::254:77", "busybox", "top") - assert.Assert(c, waitRun("c0"), check.IsNil) + assert.Assert(c, waitRun("c0"), checker.IsNil) dockerCmd(c, "run", "-d", "--name", "c1", "--net=n0", "--link-local-ip", "169.254.8.8", "--link-local-ip", "fe80::254:88", "busybox", "top") - assert.Assert(c, waitRun("c1"), check.IsNil) + assert.Assert(c, waitRun("c1"), checker.IsNil) // run a container on the default network and connect it to the test network specifying a link-local address dockerCmd(c, "run", "-d", "--name", "c2", "busybox", "top") - assert.Assert(c, waitRun("c2"), check.IsNil) + assert.Assert(c, waitRun("c2"), checker.IsNil) dockerCmd(c, "network", "connect", "--link-local-ip", "169.254.9.9", "n0", "c2") // verify the three containers can ping each other via the link-local addresses @@ -1446,13 +1446,13 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *testing.T) dockerCmd(c, "network", "create", "-d", "bridge", "foo2") dockerCmd(c, "run", "-d", "--net=foo1", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // run a container in a user-defined network with a link for an existing container // and a link for a container that doesn't exist dockerCmd(c, "run", "-d", "--net=foo1", "--name=second", "--link=first:FirstInFoo1", "--link=third:bar", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // ping to first and its alias FirstInFoo1 must succeed _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -1520,10 +1520,10 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) dockerCmd(c, "network", "create", "-d", "bridge", "net2") cid, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=first", "--net-alias=foo", "busybox:glibc", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // ping first container and its alias _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -1574,10 +1574,10 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "br.net1") dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c1.net1", "busybox:glibc", "top") - assert.Assert(c, waitRun("c1.net1"), check.IsNil) + assert.Assert(c, waitRun("c1.net1"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c2.net1", "busybox:glibc", "top") - assert.Assert(c, waitRun("c2.net1"), check.IsNil) + assert.Assert(c, waitRun("c2.net1"), checker.IsNil) // ping first container by its unqualified name _, _, err := dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1") @@ -1602,7 +1602,7 @@ func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *testing.T) { func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T) { dockerCmd(c, "run", "-d", "--name=bb", "busybox", "top") - assert.Assert(c, waitRun("bb"), check.IsNil) + assert.Assert(c, waitRun("bb"), checker.IsNil) defer dockerCmd(c, "stop", "bb") ns0 := inspectField(c, "bb", "NetworkSettings.Networks.bridge") @@ -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, check.Equals, ns0) + assert.Assert(c, ns1, checker.Equals, ns0) } func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) { @@ -1622,9 +1622,9 @@ func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) { assert.Assert(c, nr.Internal, checker.True) dockerCmd(c, "run", "-d", "--net=internal", "--name=first", "busybox:glibc", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=internal", "--name=second", "busybox:glibc", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) out, _, err := dockerCmdWithError("exec", "first", "ping", "-W", "4", "-c", "1", "8.8.8.8") assert.ErrorContains(c, err, "") assert.Assert(c, out, checker.Contains, "100% packet loss") @@ -1733,7 +1733,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *testing.T) { _, _, err = dockerCmdWithError("run", "-d", "--name", "mynet0", "--net=mynet", "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top") assert.NilError(c, err) - assert.Assert(c, waitRun("mynet0"), check.IsNil) + assert.Assert(c, waitRun("mynet0"), checker.IsNil) verifyIPAddressConfig(c, "mynet0", "mynet", "172.28.99.88", "2001:db8:1234::9988") verifyIPAddresses(c, "mynet0", "mynet", "172.28.99.88", "2001:db8:1234::9988") diff --git a/integration-cli/docker_cli_port_test.go b/integration-cli/docker_cli_port_test.go index 09407d92ee..832c300a31 100644 --- a/integration-cli/docker_cli_port_test.go +++ b/integration-cli/docker_cli_port_test.go @@ -335,14 +335,14 @@ func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) { dockerCmd(c, "run", "--net", "internal-net", "-d", "--name", "c1", "-p", "8080:8080", "busybox", "nc", "-l", "-p", "8080") - assert.Assert(c, waitRun("c1"), check.IsNil) + assert.Assert(c, waitRun("c1"), checker.IsNil) _, _, err := dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080") - assert.Assert(c, err, check.NotNil, check.Commentf("Port mapping on internal network is expected to fail")) + assert.Assert(c, err, checker.NotNil, check.Commentf("Port mapping on internal network is expected to fail")) // Connect container to another normal bridge network dockerCmd(c, "network", "create", "-d", "bridge", "foo-net") dockerCmd(c, "network", "connect", "foo-net", "c1") _, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080") - assert.Assert(c, err, check.IsNil, check.Commentf("Port mapping on the new network is expected to succeed")) + assert.Assert(c, err, checker.IsNil, check.Commentf("Port mapping on the new network is expected to succeed")) } diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index cc2e4d9d50..6b3b4bcfe7 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -211,13 +211,13 @@ func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet") dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // run a container in user-defined network udlinkNet with a link for an existing container // and a link for a container that doesn't exist dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=second", "--link=first:foo", "--link=third:bar", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // ping to first and its alias foo must succeed _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -233,7 +233,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) { // start third container now dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=third", "busybox", "top") - assert.Assert(c, waitRun("third"), check.IsNil) + assert.Assert(c, waitRun("third"), checker.IsNil) // ping to third and its alias must succeed now _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "third") @@ -247,11 +247,11 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet") dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=second", "--link=first:foo", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // ping to first and its alias foo must succeed _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -261,7 +261,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) { // Restart first container dockerCmd(c, "restart", "first") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // ping to first and its alias foo must still succeed _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -271,7 +271,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) { // Restart second container dockerCmd(c, "restart", "second") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // ping to first and its alias foo must still succeed _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -296,7 +296,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "net1") cid1, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=first", "--net-alias=foo1", "--net-alias=foo2", "busybox:glibc", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // Check if default short-id alias is added automatically id := strings.TrimSpace(cid1) @@ -304,7 +304,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) { assert.Assert(c, aliases, checker.Contains, stringid.TruncateID(id)) cid2, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Check if default short-id alias is added automatically id = strings.TrimSpace(cid2) @@ -324,7 +324,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) { // Restart first container dockerCmd(c, "restart", "first") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // ping to first and its network-scoped aliases must succeed _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") @@ -2815,7 +2815,7 @@ func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) { name := "ibuildthecloud" dockerCmd(c, "run", "-d", "--pid=host", "--name", name, "busybox", "sh", "-c", "sleep 30; echo hi") - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) errchan := make(chan error) go func() { @@ -3210,11 +3210,11 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) { testRequires(c, DaemonIsLinux) name := "unique_name" _, _, err := dockerCmdWithError("run", "--name", name, "--link", "nothing:nothing", "busybox") - assert.Assert(c, err, check.NotNil, check.Commentf("Expected docker run to fail!")) + assert.Assert(c, err, checker.NotNil, check.Commentf("Expected docker run to fail!")) 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, check.Equals, "", 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)) } func (s *DockerSuite) TestRunNamedVolume(c *testing.T) { @@ -3223,10 +3223,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), check.Equals, "hello") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello") out, _ = dockerCmd(c, "run", "-v", "testing:"+prefix+"/foo", "busybox", "sh", "-c", "cat "+prefix+"/foo/bar") - assert.Assert(c, strings.TrimSpace(out), check.Equals, "hello") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello") } func (s *DockerSuite) TestRunWithUlimits(c *testing.T) { @@ -3466,7 +3466,7 @@ func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork") dockerCmd(c, "run", "-d", "--net=testnetwork", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-t", "--net=testnetwork", "--name=second", "busybox", "ping", "-c", "1", "first") } @@ -3477,9 +3477,9 @@ func (s *DockerSuite) TestContainersInMultipleNetworks(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2") // Run and connect containers to testnetwork1 dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Check connectivity between containers in testnetwork2 dockerCmd(c, "exec", "first", "ping", "-c", "1", "second.testnetwork1") // Connect containers to testnetwork2 @@ -3496,9 +3496,9 @@ func (s *DockerSuite) TestContainersNetworkIsolation(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2") // Run 1 container in testnetwork1 and another in testnetwork2 dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=testnetwork2", "--name=second", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Check Isolation between containers : ping must fail _, _, err := dockerCmdWithError("exec", "first", "ping", "-c", "1", "second") @@ -3522,9 +3522,9 @@ func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *testing.T) { dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") // Run and connect containers to testnetwork1 dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Network delete with active containers must fail _, _, err := dockerCmdWithError("network", "rm", "testnetwork1") assert.ErrorContains(c, err, "") @@ -3542,9 +3542,9 @@ func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *testing.T) { // Run and connect containers to testnetwork1 dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Check connectivity between containers in testnetwork2 dockerCmd(c, "exec", "first", "ping", "-c", "1", "second.testnetwork1") // Connect containers to testnetwork2 @@ -3570,7 +3570,7 @@ func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) // Run a container with --net=host dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // Create a network using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3583,10 +3583,10 @@ func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) { func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // Run second container in first container's network namespace dockerCmd(c, "run", "-d", "--net=container:first", "--name=second", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Create a network using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3600,7 +3600,7 @@ func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) { func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "-d", "--net=none", "--name=first", "busybox", "top") - assert.Assert(c, waitRun("first"), check.IsNil) + assert.Assert(c, waitRun("first"), checker.IsNil) // Create a network using bridge driver dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1") @@ -3612,7 +3612,7 @@ func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) { // create a container connected to testnetwork1 dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top") - assert.Assert(c, waitRun("second"), check.IsNil) + assert.Assert(c, waitRun("second"), checker.IsNil) // Connect second container to none network. it must fail as well _, _, err = dockerCmdWithError("network", "connect", "none", "second") @@ -3628,7 +3628,7 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) { stdout := bytes.NewBuffer(nil) cmd.Stdout = stdout cmd.Stderr = stdout - assert.Assert(c, cmd.Start(), check.IsNil) + assert.Assert(c, cmd.Start(), checker.IsNil) waitChan := make(chan error) go func() { @@ -3637,7 +3637,7 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) { select { case err := <-waitChan: - assert.Assert(c, err, check.IsNil, check.Commentf(stdout.String())) + assert.Assert(c, err, checker.IsNil, check.Commentf(stdout.String())) case <-time.After(30 * time.Second): c.Fatal("timeout waiting for command to exit") } @@ -3872,7 +3872,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), check.Equals, "hello") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello") } func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *testing.T) { @@ -3944,7 +3944,7 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) { runSleepingContainer(c, "--name=test", "-p", "8000:8000") // Wait until container is fully up and running - assert.Assert(c, waitRun("test"), check.IsNil) + assert.Assert(c, waitRun("test"), checker.IsNil) out, _, err := dockerCmdWithError("run", "--name=fail", "-p", "8000:8000", "busybox", "true") // We will need the following `inspect` to diagnose the issue if test fails (#21247) @@ -4104,7 +4104,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), check.Equals, "foo") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "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{ @@ -4497,8 +4497,8 @@ func (s *DockerSuite) TestRunMount(c *testing.T) { _, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName}, append(opts, []string{"busybox", "top"}...)...)...) if testCase.valid { - assert.Assert(c, err, check.IsNil, check.Commentf("got error while creating a container with %v (%s)", opts, cName)) - assert.Assert(c, testCase.fn(cName), check.IsNil, check.Commentf("got error while executing test for %v (%s)", opts, cName)) + assert.Assert(c, err, checker.IsNil, check.Commentf("got error while creating a container with %v (%s)", opts, cName)) + assert.Assert(c, testCase.fn(cName), checker.IsNil, check.Commentf("got error while executing test for %v (%s)", opts, cName)) dockerCmd(c, "rm", "-f", cName) } else { assert.Assert(c, err, checker.NotNil, check.Commentf("got nil while creating a container with %v (%s)", opts, cName)) diff --git a/integration-cli/docker_cli_run_unix_test.go b/integration-cli/docker_cli_run_unix_test.go index ce7fcdaff5..df47d91af6 100644 --- a/integration-cli/docker_cli_run_unix_test.go +++ b/integration-cli/docker_cli_run_unix_test.go @@ -108,7 +108,7 @@ func (s *DockerSuite) TestRunAttachDetach(c *testing.T) { defer cpty.Close() cmd.Stdin = tty assert.NilError(c, cmd.Start()) - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) _, err = cpty.Write([]byte("hello\n")) assert.NilError(c, err) @@ -167,7 +167,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) { if err := cmd.Start(); err != nil { c.Fatal(err) } - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) if _, err := cpty.Write([]byte("hello\n")); err != nil { c.Fatal(err) @@ -210,7 +210,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) { func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *testing.T) { name := "attach-detach" dockerCmd(c, "run", "--name", name, "-itd", "busybox", "top") - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) // specify an invalid detach key, container will ignore it and use default cmd := exec.Command(dockerBinary, "attach", "--detach-keys=ctrl-A,a", name) @@ -283,7 +283,7 @@ func (s *DockerSuite) TestRunAttachDetachFromConfig(c *testing.T) { if err := cmd.Start(); err != nil { c.Fatal(err) } - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) if _, err := cpty.Write([]byte("hello\n")); err != nil { c.Fatal(err) @@ -366,7 +366,7 @@ func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) { if err := cmd.Start(); err != nil { c.Fatal(err) } - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) if _, err := cpty.Write([]byte("hello\n")); err != nil { c.Fatal(err) @@ -427,7 +427,7 @@ func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing. c.Fatal(err) } go cmd.Wait() - assert.Assert(c, waitRun(name), check.IsNil) + assert.Assert(c, waitRun(name), checker.IsNil) // Invalid escape sequence aba, should print aba in output if _, err := cpty.Write(keyA); err != nil { @@ -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, check.Equals, "67108864") + assert.Assert(c, shmSize, checker.Equals, "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, check.Equals, "1073741824") + assert.Assert(c, shmSize, checker.Equals, "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), check.Equals, "1") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "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"], check.Equals, "1") + assert.Assert(c, sysctls["net.ipv4.ip_forward"], checker.Equals, "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), check.Equals, "0") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "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"], check.Equals, "0") + assert.Assert(c, sysctls["net.ipv4.ip_forward"], checker.Equals, "0") icmd.RunCommand(dockerBinary, "run", "--sysctl", "kernel.foobar=1", "--name", "test2", "busybox", "cat", "/proc/sys/kernel/foobar").Assert(c, icmd.Expected{ diff --git a/integration-cli/docker_cli_save_load_test.go b/integration-cli/docker_cli_save_load_test.go index 0e319300e6..c9d73ac0df 100644 --- a/integration-cli/docker_cli_save_load_test.go +++ b/integration-cli/docker_cli_save_load_test.go @@ -129,8 +129,8 @@ func (s *DockerSuite) TestSaveImageId(c *testing.T) { cleanedShortImageID := strings.TrimSpace(out) // Make sure IDs are not empty - assert.Assert(c, cleanedLongImageID, checker.Not(check.Equals), "", check.Commentf("Id should not be empty.")) - assert.Assert(c, cleanedShortImageID, checker.Not(check.Equals), "", check.Commentf("Id should not be empty.")) + assert.Assert(c, cleanedLongImageID, checker.Not(checker.Equals), "", check.Commentf("Id should not be empty.")) + assert.Assert(c, cleanedShortImageID, checker.Not(checker.Equals), "", check.Commentf("Id should not be empty.")) saveCmd := exec.Command(dockerBinary, "save", cleanedShortImageID) tarCmd := exec.Command("tar", "t") diff --git a/integration-cli/docker_cli_service_health_test.go b/integration-cli/docker_cli_service_health_test.go index df7a4af50e..fffddc51b6 100644 --- a/integration-cli/docker_cli_service_health_test.go +++ b/integration-cli/docker_cli_service_health_test.go @@ -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, check.Equals, swarm.TaskStateStarting) + assert.Assert(c, task.Status.State, checker.Equals, swarm.TaskStateStarting) // make it healthy d.Cmd("exec", containerID, "touch", "/status") diff --git a/integration-cli/docker_cli_swarm_test.go b/integration-cli/docker_cli_swarm_test.go index 888d1528a4..26cdd586d0 100644 --- a/integration-cli/docker_cli_swarm_test.go +++ b/integration-cli/docker_cli_swarm_test.go @@ -803,7 +803,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) { mux := http.NewServeMux() s.server = httptest.NewServer(mux) - assert.Assert(c, s.server, check.NotNil) // check that HTTP server has started + assert.Assert(c, s.server, checker.NotNil) // check that HTTP server has started setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin) defer func() { s.server.Close() diff --git a/integration-cli/docker_cli_volume_test.go b/integration-cli/docker_cli_volume_test.go index c4fc448c19..8dc7b5b007 100644 --- a/integration-cli/docker_cli_volume_test.go +++ b/integration-cli/docker_cli_volume_test.go @@ -29,23 +29,23 @@ 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, check.Equals, "test") + assert.Assert(c, name, checker.Equals, "test") out, _ = dockerCmd(c, "volume", "create", "test2") name = strings.TrimSpace(out) - assert.Assert(c, name, check.Equals, "test2") + assert.Assert(c, name, checker.Equals, "test2") } func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) { - assert.Assert(c, exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run(), check.Not(check.IsNil), check.Commentf("volume inspect should error on non-existent volume")) + assert.Assert(c, exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run(), checker.Not(checker.IsNil), check.Commentf("volume inspect should error on non-existent volume")) out, _ := dockerCmd(c, "volume", "create") name := strings.TrimSpace(out) out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", name) - assert.Assert(c, strings.TrimSpace(out), check.Equals, name) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, name) dockerCmd(c, "volume", "create", "test") out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", "test") - assert.Assert(c, strings.TrimSpace(out), check.Equals, "test") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "test") } func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) { @@ -141,7 +141,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) { out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=false") // Explicitly disabling dangling - assert.Assert(c, out, check.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) + assert.Assert(c, out, checker.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output")) assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output")) @@ -149,23 +149,23 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) { // Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) - assert.Assert(c, out, check.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected")) - assert.Assert(c, out, check.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected")) + assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected")) + assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected")) out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=1") // Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output, dangling also accept 1 assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) - assert.Assert(c, out, check.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected")) - assert.Assert(c, out, check.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected")) + assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected")) + assert.Assert(c, out, checker.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected")) out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=0") // dangling=0 is same as dangling=false case - assert.Assert(c, out, check.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) + assert.Assert(c, out, checker.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output")) assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output")) out, _ = dockerCmd(c, "volume", "ls", "--filter", "name=testisin") - assert.Assert(c, out, check.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) + assert.Assert(c, out, checker.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output")) assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output")) assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output")) } @@ -200,17 +200,17 @@ 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), check.Equals, "hello") + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "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), check.Equals, "hello", check.Commentf("volume data was removed")) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello", check.Commentf("volume data was removed")) dockerCmd(c, "rm", "test2") dockerCmd(c, "volume", "rm", volumeID) - assert.Assert(c, exec.Command("volume", "rm", "doesnotexist").Run(), check.Not(check.IsNil), check.Commentf("volume rm should fail with non-existent volume")) + assert.Assert(c, exec.Command("volume", "rm", "doesnotexist").Run(), checker.Not(checker.IsNil), check.Commentf("volume rm should fail with non-existent volume")) } // FIXME(vdemeester) should be a unit test in cli/command/volume package @@ -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), check.Equals, testValue) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, 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), check.Equals, v) + assert.Assert(c, strings.TrimSpace(out), checker.Equals, v) } } @@ -329,15 +329,15 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) { // filter with label=key=value assert.Assert(c, out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output")) - assert.Assert(c, out, check.Not(checker.Contains), "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2 in output")) + assert.Assert(c, out, checker.Not(checker.Contains), "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2 in output")) out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=non-exist") outArr := strings.Split(strings.TrimSpace(out), "\n") - assert.Assert(c, len(outArr), check.Equals, 1, check.Commentf("\n%s", out)) + assert.Assert(c, len(outArr), checker.Equals, 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), check.Equals, 1, check.Commentf("\n%s", out)) + assert.Assert(c, len(outArr), checker.Equals, 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), check.Equals, 1, check.Commentf("\n%s", out)) + assert.Assert(c, len(outArr), checker.Equals, 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), check.Equals, 1, check.Commentf("\n%s", out)) + assert.Assert(c, len(outArr), checker.Equals, 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), check.Equals, 1, check.Commentf("\n%s", out)) + assert.Assert(c, len(outArr), checker.Equals, 1, check.Commentf("\n%s", out)) } func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *testing.T) { @@ -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, check.Equals, 0) + assert.Assert(c, e, checker.Equals, 0) _, e = dockerCmd(c, "volume", "rm", "-f", name) - assert.Assert(c, e, check.Equals, 0) + assert.Assert(c, e, checker.Equals, 0) out, e = dockerCmd(c, "volume", "ls") - assert.Assert(c, e, check.Equals, 0) + assert.Assert(c, e, checker.Equals, 0) assert.Assert(c, out, checker.Not(checker.Contains), name) } diff --git a/integration-cli/docker_utils_test.go b/integration-cli/docker_utils_test.go index 5852afae50..31f3502304 100644 --- a/integration-cli/docker_utils_test.go +++ b/integration-cli/docker_utils_test.go @@ -77,7 +77,7 @@ func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interfac str := inspectFieldJSON(c, name, field) err := json.Unmarshal([]byte(str), output) if c != nil { - assert.Assert(c, err, check.IsNil, check.Commentf("failed to unmarshal: %v", err)) + assert.Assert(c, err, checker.IsNil, check.Commentf("failed to unmarshal: %v", err)) } } @@ -201,7 +201,7 @@ func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result { // Fail the test when error occurs. func writeFile(dst, content string, c *testing.T) { // Create subdirectories if necessary - assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700), check.IsNil) + assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700), checker.IsNil) f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700) assert.NilError(c, err) defer f.Close() @@ -263,7 +263,7 @@ func daemonTime(c *testing.T) time.Time { assert.NilError(c, err) dt, err := time.Parse(time.RFC3339Nano, info.SystemTime) - assert.Assert(c, err, check.IsNil, check.Commentf("invalid time format in GET /info response")) + assert.Assert(c, err, checker.IsNil, check.Commentf("invalid time format in GET /info response")) return dt } @@ -408,7 +408,7 @@ func waitForGoroutines(expected int) error { // getErrorMessage returns the error message from an error API response func getErrorMessage(c *testing.T, body []byte) string { var resp types.ErrorResponse - assert.Assert(c, json.Unmarshal(body, &resp), check.IsNil) + assert.Assert(c, json.Unmarshal(body, &resp), checker.IsNil) return strings.TrimSpace(resp.Message) } diff --git a/pkg/discovery/discovery_test.go b/pkg/discovery/discovery_test.go index 11c74040a5..6bac6ec1ec 100644 --- a/pkg/discovery/discovery_test.go +++ b/pkg/discovery/discovery_test.go @@ -15,64 +15,64 @@ var _ = check.Suite(&DiscoverySuite{}) func (s *DiscoverySuite) TestNewEntry(c *testing.T) { entry, err := NewEntry("127.0.0.1:2375") - assert.Assert(c, err, check.IsNil) - assert.Assert(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true) - assert.Assert(c, entry.String(), check.Equals, "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") entry, err = NewEntry("[2001:db8:0:f101::2]:2375") - assert.Assert(c, err, check.IsNil) - assert.Assert(c, entry.Equals(&Entry{Host: "2001:db8:0:f101::2", Port: "2375"}), check.Equals, true) - assert.Assert(c, entry.String(), check.Equals, "[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") _, err = NewEntry("127.0.0.1") - assert.Assert(c, err, check.NotNil) + assert.Assert(c, err, checker.NotNil) } func (s *DiscoverySuite) TestParse(c *testing.T) { scheme, uri := parse("127.0.0.1:2375") - assert.Assert(c, scheme, check.Equals, "nodes") - assert.Assert(c, uri, check.Equals, "127.0.0.1:2375") + assert.Assert(c, scheme, checker.Equals, "nodes") + assert.Assert(c, uri, checker.Equals, "127.0.0.1:2375") scheme, uri = parse("localhost:2375") - assert.Assert(c, scheme, check.Equals, "nodes") - assert.Assert(c, uri, check.Equals, "localhost:2375") + assert.Assert(c, scheme, checker.Equals, "nodes") + assert.Assert(c, uri, checker.Equals, "localhost:2375") scheme, uri = parse("scheme://127.0.0.1:2375") - assert.Assert(c, scheme, check.Equals, "scheme") - assert.Assert(c, uri, check.Equals, "127.0.0.1:2375") + assert.Assert(c, scheme, checker.Equals, "scheme") + assert.Assert(c, uri, checker.Equals, "127.0.0.1:2375") scheme, uri = parse("scheme://localhost:2375") - assert.Assert(c, scheme, check.Equals, "scheme") - assert.Assert(c, uri, check.Equals, "localhost:2375") + assert.Assert(c, scheme, checker.Equals, "scheme") + assert.Assert(c, uri, checker.Equals, "localhost:2375") scheme, uri = parse("") - assert.Assert(c, scheme, check.Equals, "nodes") - assert.Assert(c, uri, check.Equals, "") + assert.Assert(c, scheme, checker.Equals, "nodes") + assert.Assert(c, uri, checker.Equals, "") } func (s *DiscoverySuite) TestCreateEntries(c *testing.T) { entries, err := CreateEntries(nil) - assert.Assert(c, entries, check.DeepEquals, Entries{}) - assert.Assert(c, err, check.IsNil) + assert.Assert(c, entries, checker.DeepEquals, Entries{}) + assert.Assert(c, err, checker.IsNil) entries, err = CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", "[2001:db8:0:f101::2]:2375", ""}) - assert.Assert(c, err, check.IsNil) + assert.Assert(c, err, checker.IsNil) expected := Entries{ &Entry{Host: "127.0.0.1", Port: "2375"}, &Entry{Host: "127.0.0.2", Port: "2375"}, &Entry{Host: "2001:db8:0:f101::2", Port: "2375"}, } - assert.Assert(c, entries.Equals(expected), check.Equals, true) + assert.Assert(c, entries.Equals(expected), checker.Equals, true) _, err = CreateEntries([]string{"127.0.0.1", "127.0.0.2"}) - assert.Assert(c, err, check.NotNil) + assert.Assert(c, err, checker.NotNil) } 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, check.IsNil) - assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true) - assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), check.Equals, false) + 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) } func (s *DiscoverySuite) TestEntriesEquality(c *testing.T) { @@ -85,20 +85,20 @@ func (s *DiscoverySuite) TestEntriesEquality(c *testing.T) { assert.Assert(c, entries.Equals(Entries{ &Entry{Host: "127.0.0.1", Port: "2375"}, &Entry{Host: "127.0.0.2", Port: "2375"}, - }), check.Equals, true) + }), checker.Equals, true) // Different size assert.Assert(c, entries.Equals(Entries{ &Entry{Host: "127.0.0.1", Port: "2375"}, &Entry{Host: "127.0.0.2", Port: "2375"}, &Entry{Host: "127.0.0.3", Port: "2375"}, - }), check.Equals, false) + }), checker.Equals, false) // Different content assert.Assert(c, entries.Equals(Entries{ &Entry{Host: "127.0.0.1", Port: "2375"}, &Entry{Host: "127.0.0.42", Port: "2375"}, - }), check.Equals, false) + }), checker.Equals, false) } @@ -110,25 +110,25 @@ func (s *DiscoverySuite) TestEntriesDiff(c *testing.T) { // No diff added, removed := entries.Diff(Entries{entry2, entry1}) - assert.Assert(c, added, check.HasLen, 0) - assert.Assert(c, removed, check.HasLen, 0) + assert.Assert(c, added, checker.HasLen, 0) + assert.Assert(c, removed, checker.HasLen, 0) // Add added, removed = entries.Diff(Entries{entry2, entry3, entry1}) - assert.Assert(c, added, check.HasLen, 1) - assert.Assert(c, added.Contains(entry3), check.Equals, true) - assert.Assert(c, removed, check.HasLen, 0) + assert.Assert(c, added, checker.HasLen, 1) + assert.Assert(c, added.Contains(entry3), checker.Equals, true) + assert.Assert(c, removed, checker.HasLen, 0) // Remove added, removed = entries.Diff(Entries{entry2}) - assert.Assert(c, added, check.HasLen, 0) - assert.Assert(c, removed, check.HasLen, 1) - assert.Assert(c, removed.Contains(entry1), check.Equals, true) + assert.Assert(c, added, checker.HasLen, 0) + assert.Assert(c, removed, checker.HasLen, 1) + assert.Assert(c, removed.Contains(entry1), checker.Equals, true) // Add and remove added, removed = entries.Diff(Entries{entry1, entry3}) - assert.Assert(c, added, check.HasLen, 1) - assert.Assert(c, added.Contains(entry3), check.Equals, true) - assert.Assert(c, removed, check.HasLen, 1) - assert.Assert(c, removed.Contains(entry2), check.Equals, true) + assert.Assert(c, added, checker.HasLen, 1) + assert.Assert(c, added.Contains(entry3), checker.Equals, true) + assert.Assert(c, removed, checker.HasLen, 1) + assert.Assert(c, removed.Contains(entry2), checker.Equals, true) } diff --git a/pkg/discovery/file/file_test.go b/pkg/discovery/file/file_test.go index 5d026b06dc..52749b8f96 100644 --- a/pkg/discovery/file/file_test.go +++ b/pkg/discovery/file/file_test.go @@ -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, check.Equals, "/path/to/file") + assert.Assert(c, d.path, checker.Equals, "/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, check.IsNil) - assert.Assert(c, d.(*Discovery).path, check.Equals, "/path/to/file") + assert.Assert(c, err, checker.IsNil) + assert.Assert(c, d.(*Discovery).path, checker.Equals, "/path/to/file") } func (s *DiscoverySuite) TestContent(c *testing.T) { @@ -35,17 +35,17 @@ func (s *DiscoverySuite) TestContent(c *testing.T) { 2.2.2.[2:4]:2222 ` ips := parseFileContent([]byte(data)) - assert.Assert(c, ips, check.HasLen, 5) - assert.Assert(c, ips[0], check.Equals, "1.1.1.1:1111") - assert.Assert(c, ips[1], check.Equals, "1.1.1.2:1111") - assert.Assert(c, ips[2], check.Equals, "2.2.2.2:2222") - assert.Assert(c, ips[3], check.Equals, "2.2.2.3:2222") - assert.Assert(c, ips[4], check.Equals, "2.2.2.4:2222") + 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") } func (s *DiscoverySuite) TestRegister(c *testing.T) { discovery := &Discovery{path: "/path/to/file"} - assert.Assert(c, discovery.Register("0.0.0.0"), check.NotNil) + assert.Assert(c, discovery.Register("0.0.0.0"), checker.NotNil) } func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) { @@ -58,9 +58,9 @@ func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) { ### test ### ` ips := parseFileContent([]byte(data)) - assert.Assert(c, ips, check.HasLen, 2) - assert.Assert(c, "1.1.1.1:1111", check.Equals, ips[0]) - assert.Assert(c, "3.3.3.3:3333", check.Equals, ips[1]) + 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]) } func (s *DiscoverySuite) TestWatch(c *testing.T) { @@ -75,9 +75,9 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) { // Create a temporary file and remove it. tmp, err := ioutil.TempFile(os.TempDir(), "discovery-file-test") - assert.Assert(c, err, check.IsNil) - assert.Assert(c, tmp.Close(), check.IsNil) - assert.Assert(c, os.Remove(tmp.Name()), check.IsNil) + assert.Assert(c, err, checker.IsNil) + assert.Assert(c, tmp.Close(), checker.IsNil) + assert.Assert(c, os.Remove(tmp.Name()), checker.IsNil) // Set up file discovery. d := &Discovery{} @@ -86,7 +86,7 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) { ch, errCh := d.Watch(stopCh) // Make sure it fires errors since the file doesn't exist. - assert.Assert(c, <-errCh, check.NotNil) + assert.Assert(c, <-errCh, checker.NotNil) // We have to drain the error channel otherwise Watch will get stuck. go func() { for range errCh { @@ -94,21 +94,21 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) { }() // Write the file and make sure we get the expected value back. - assert.Assert(c, ioutil.WriteFile(tmp.Name(), []byte(data), 0600), check.IsNil) - assert.Assert(c, <-ch, check.DeepEquals, expected) + assert.Assert(c, ioutil.WriteFile(tmp.Name(), []byte(data), 0600), checker.IsNil) + assert.Assert(c, <-ch, checker.DeepEquals, expected) // Add a new entry and look it up. expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"}) f, err := os.OpenFile(tmp.Name(), os.O_APPEND|os.O_WRONLY, 0600) - assert.Assert(c, err, check.IsNil) - assert.Assert(c, f, check.NotNil) + assert.Assert(c, err, checker.IsNil) + assert.Assert(c, f, checker.NotNil) _, err = f.WriteString("\n3.3.3.3:3333\n") - assert.Assert(c, err, check.IsNil) + assert.Assert(c, err, checker.IsNil) f.Close() - assert.Assert(c, <-ch, check.DeepEquals, expected) + assert.Assert(c, <-ch, checker.DeepEquals, expected) // Stop and make sure it closes all channels. close(stopCh) - assert.Assert(c, <-ch, check.IsNil) - assert.Assert(c, <-errCh, check.IsNil) + assert.Assert(c, <-ch, checker.IsNil) + assert.Assert(c, <-errCh, checker.IsNil) } diff --git a/pkg/discovery/generator_test.go b/pkg/discovery/generator_test.go index cbfbf8ec8e..8bbc15ba2a 100644 --- a/pkg/discovery/generator_test.go +++ b/pkg/discovery/generator_test.go @@ -6,48 +6,48 @@ import ( func (s *DiscoverySuite) TestGeneratorNotGenerate(c *testing.T) { ips := Generate("127.0.0.1") - assert.Assert(c, len(ips), check.Equals, 1) - assert.Assert(c, ips[0], check.Equals, "127.0.0.1") + assert.Assert(c, len(ips), checker.Equals, 1) + assert.Assert(c, ips[0], checker.Equals, "127.0.0.1") } func (s *DiscoverySuite) TestGeneratorWithPortNotGenerate(c *testing.T) { ips := Generate("127.0.0.1:8080") - assert.Assert(c, len(ips), check.Equals, 1) - assert.Assert(c, ips[0], check.Equals, "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") } func (s *DiscoverySuite) TestGeneratorMatchFailedNotGenerate(c *testing.T) { ips := Generate("127.0.0.[1]") - assert.Assert(c, len(ips), check.Equals, 1) - assert.Assert(c, ips[0], check.Equals, "127.0.0.[1]") + assert.Assert(c, len(ips), checker.Equals, 1) + assert.Assert(c, ips[0], checker.Equals, "127.0.0.[1]") } func (s *DiscoverySuite) TestGeneratorWithPort(c *testing.T) { ips := Generate("127.0.0.[1:11]:2375") - assert.Assert(c, len(ips), check.Equals, 11) - assert.Assert(c, ips[0], check.Equals, "127.0.0.1:2375") - assert.Assert(c, ips[1], check.Equals, "127.0.0.2:2375") - assert.Assert(c, ips[2], check.Equals, "127.0.0.3:2375") - assert.Assert(c, ips[3], check.Equals, "127.0.0.4:2375") - assert.Assert(c, ips[4], check.Equals, "127.0.0.5:2375") - assert.Assert(c, ips[5], check.Equals, "127.0.0.6:2375") - assert.Assert(c, ips[6], check.Equals, "127.0.0.7:2375") - assert.Assert(c, ips[7], check.Equals, "127.0.0.8:2375") - assert.Assert(c, ips[8], check.Equals, "127.0.0.9:2375") - assert.Assert(c, ips[9], check.Equals, "127.0.0.10:2375") - assert.Assert(c, ips[10], check.Equals, "127.0.0.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") } func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeStart(c *testing.T) { malformedInput := "127.0.0.[x:11]:2375" ips := Generate(malformedInput) - assert.Assert(c, len(ips), check.Equals, 1) - assert.Assert(c, ips[0], check.Equals, malformedInput) + assert.Assert(c, len(ips), checker.Equals, 1) + assert.Assert(c, ips[0], checker.Equals, malformedInput) } func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *testing.T) { malformedInput := "127.0.0.[1:x]:2375" ips := Generate(malformedInput) - assert.Assert(c, len(ips), check.Equals, 1) - assert.Assert(c, ips[0], check.Equals, malformedInput) + assert.Assert(c, len(ips), checker.Equals, 1) + assert.Assert(c, ips[0], checker.Equals, malformedInput) } diff --git a/pkg/discovery/kv/kv_test.go b/pkg/discovery/kv/kv_test.go index 083a2cacad..e2ec3a8fb1 100644 --- a/pkg/discovery/kv/kv_test.go +++ b/pkg/discovery/kv/kv_test.go @@ -30,9 +30,9 @@ func (ds *DiscoverySuite) TestInitialize(c *testing.T) { d.store = storeMock s := d.store.(*FakeStore) - assert.Assert(c, s.Endpoints, check.HasLen, 1) - assert.Assert(c, s.Endpoints[0], check.Equals, "127.0.0.1") - assert.Assert(c, d.path, check.Equals, defaultDiscoveryPath) + 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) storeMock = &FakeStore{ Endpoints: []string{"127.0.0.1:1234"}, @@ -42,9 +42,9 @@ func (ds *DiscoverySuite) TestInitialize(c *testing.T) { d.store = storeMock s = d.store.(*FakeStore) - assert.Assert(c, s.Endpoints, check.HasLen, 1) - assert.Assert(c, s.Endpoints[0], check.Equals, "127.0.0.1:1234") - assert.Assert(c, d.path, check.Equals, "path/"+defaultDiscoveryPath) + 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) storeMock = &FakeStore{ Endpoints: []string{"127.0.0.1:1234", "127.0.0.2:1234", "127.0.0.3:1234"}, @@ -54,12 +54,12 @@ func (ds *DiscoverySuite) TestInitialize(c *testing.T) { d.store = storeMock s = d.store.(*FakeStore) - assert.Assert(c, s.Endpoints, check.HasLen, 3) - assert.Assert(c, s.Endpoints[0], check.Equals, "127.0.0.1:1234") - assert.Assert(c, s.Endpoints[1], check.Equals, "127.0.0.2:1234") - assert.Assert(c, s.Endpoints[2], check.Equals, "127.0.0.3:1234") + 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.Assert(c, d.path, check.Equals, "path/"+defaultDiscoveryPath) + assert.Assert(c, d.path, checker.Equals, "path/"+defaultDiscoveryPath) } // Extremely limited mock store so we can test initialization @@ -181,12 +181,12 @@ BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I= -----END RSA PRIVATE KEY----- ` certFile, err := ioutil.TempFile("", "cert") - assert.Assert(c, err, check.IsNil) + assert.Assert(c, err, checker.IsNil) defer os.Remove(certFile.Name()) certFile.Write([]byte(cert)) certFile.Close() keyFile, err := ioutil.TempFile("", "key") - assert.Assert(c, err, check.IsNil) + assert.Assert(c, err, checker.IsNil) defer os.Remove(keyFile.Name()) keyFile.Write([]byte(key)) keyFile.Close() @@ -198,11 +198,11 @@ BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I= "kv.certfile": certFile.Name(), "kv.keyfile": keyFile.Name(), }) - assert.Assert(c, err, check.IsNil) + assert.Assert(c, err, checker.IsNil) s := d.store.(*Mock) - assert.Assert(c, s.Options.TLS, check.NotNil) - assert.Assert(c, s.Options.TLS.RootCAs, check.NotNil) - assert.Assert(c, s.Options.TLS.Certificates, check.HasLen, 1) + assert.Assert(c, s.Options.TLS, checker.NotNil) + assert.Assert(c, s.Options.TLS.RootCAs, checker.NotNil) + assert.Assert(c, s.Options.TLS.Certificates, checker.HasLen, 1) } func (ds *DiscoverySuite) TestWatch(c *testing.T) { @@ -239,13 +239,13 @@ func (ds *DiscoverySuite) TestWatch(c *testing.T) { // Push the entries into the store channel and make sure discovery emits. mockCh <- kvs - assert.Assert(c, <-ch, check.DeepEquals, expected) + assert.Assert(c, <-ch, checker.DeepEquals, expected) // Add a new entry. expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"}) kvs = append(kvs, &store.KVPair{Key: path.Join("path", defaultDiscoveryPath, "3.3.3.3"), Value: []byte("3.3.3.3:3333")}) mockCh <- kvs - assert.Assert(c, <-ch, check.DeepEquals, expected) + assert.Assert(c, <-ch, checker.DeepEquals, expected) close(mockCh) // Give it enough time to call WatchTree. @@ -253,8 +253,8 @@ func (ds *DiscoverySuite) TestWatch(c *testing.T) { // Stop and make sure it closes all channels. close(stopCh) - assert.Assert(c, <-ch, check.IsNil) - assert.Assert(c, <-errCh, check.IsNil) + assert.Assert(c, <-ch, checker.IsNil) + assert.Assert(c, <-errCh, checker.IsNil) } // FakeStore implements store.Store methods. It mocks all store diff --git a/pkg/discovery/memory/memory_test.go b/pkg/discovery/memory/memory_test.go index 9fd7874577..6545f0bc4e 100644 --- a/pkg/discovery/memory/memory_test.go +++ b/pkg/discovery/memory/memory_test.go @@ -30,19 +30,19 @@ func (s *discoverySuite) TestWatch(c *testing.T) { &discovery.Entry{Host: "1.1.1.1", Port: "1111"}, } - assert.Assert(c, d.Register("1.1.1.1:1111"), check.IsNil) - assert.Assert(c, <-ch, check.DeepEquals, expected) + assert.Assert(c, d.Register("1.1.1.1:1111"), checker.IsNil) + assert.Assert(c, <-ch, checker.DeepEquals, expected) expected = discovery.Entries{ &discovery.Entry{Host: "1.1.1.1", Port: "1111"}, &discovery.Entry{Host: "2.2.2.2", Port: "2222"}, } - assert.Assert(c, d.Register("2.2.2.2:2222"), check.IsNil) - assert.Assert(c, <-ch, check.DeepEquals, expected) + assert.Assert(c, d.Register("2.2.2.2:2222"), checker.IsNil) + assert.Assert(c, <-ch, checker.DeepEquals, expected) // Stop and make sure it closes all channels. close(stopCh) - assert.Assert(c, <-ch, check.IsNil) - assert.Assert(c, <-errCh, check.IsNil) + assert.Assert(c, <-ch, checker.IsNil) + assert.Assert(c, <-errCh, checker.IsNil) } diff --git a/pkg/discovery/nodes/nodes_test.go b/pkg/discovery/nodes/nodes_test.go index 5f8e7263a0..3dc20ac3a6 100644 --- a/pkg/discovery/nodes/nodes_test.go +++ b/pkg/discovery/nodes/nodes_test.go @@ -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), check.Equals, 2) - assert.Assert(c, d.entries[0].String(), check.Equals, "1.1.1.1:1111") - assert.Assert(c, d.entries[1].String(), check.Equals, "2.2.2.2:2222") + 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") } 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), check.Equals, 5) - assert.Assert(c, d.entries[0].String(), check.Equals, "1.1.1.1:1111") - assert.Assert(c, d.entries[1].String(), check.Equals, "1.1.1.2:1111") - assert.Assert(c, d.entries[2].String(), check.Equals, "2.2.2.2:2222") - assert.Assert(c, d.entries[3].String(), check.Equals, "2.2.2.3:2222") - assert.Assert(c, d.entries[4].String(), check.Equals, "2.2.2.4:2222") + 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") } func (s *DiscoverySuite) TestWatch(c *testing.T) { @@ -42,10 +42,10 @@ 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), check.Equals, true) + assert.Assert(c, expected.Equals(<-ch), checker.Equals, true) } func (s *DiscoverySuite) TestRegister(c *testing.T) { d := &Discovery{} - assert.Assert(c, d.Register("0.0.0.0"), check.NotNil) + assert.Assert(c, d.Register("0.0.0.0"), checker.NotNil) }