Skip to content

Commit c8da7fb

Browse files
Tibor VassthaJeztah
authored andcommitted
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 <tibor@docker.com> (cherry picked from commit 230f7bc) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 99deded commit c8da7fb

28 files changed

+347
-347
lines changed

integration-cli/docker_api_containers_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
14571457
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
14581458
assert.NilError(c, err)
14591459

1460-
assert.Assert(c, containerJSON.HostConfig.ShmSize, check.Equals, defaultSHMSize)
1460+
assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, defaultSHMSize)
14611461

14621462
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
14631463
shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
@@ -1484,7 +1484,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
14841484
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
14851485
assert.NilError(c, err)
14861486

1487-
assert.Assert(c, containerJSON.HostConfig.ShmSize, check.Equals, int64(67108864))
1487+
assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, int64(67108864))
14881488

14891489
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
14901490
shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
@@ -1515,7 +1515,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
15151515
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
15161516
assert.NilError(c, err)
15171517

1518-
assert.Assert(c, containerJSON.HostConfig.ShmSize, check.Equals, int64(1073741824))
1518+
assert.Assert(c, containerJSON.HostConfig.ShmSize, checker.Equals, int64(1073741824))
15191519

15201520
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
15211521
shmRegex := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=1048576k`)
@@ -1542,9 +1542,9 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
15421542
assert.NilError(c, err)
15431543

15441544
if versions.LessThan(testEnv.DaemonAPIVersion(), "1.31") {
1545-
assert.Assert(c, *containerJSON.HostConfig.MemorySwappiness, check.Equals, int64(-1))
1545+
assert.Assert(c, *containerJSON.HostConfig.MemorySwappiness, checker.Equals, int64(-1))
15461546
} else {
1547-
assert.Assert(c, containerJSON.HostConfig.MemorySwappiness, check.IsNil)
1547+
assert.Assert(c, containerJSON.HostConfig.MemorySwappiness, checker.IsNil)
15481548
}
15491549
}
15501550

@@ -1614,7 +1614,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
16141614
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
16151615
assert.NilError(c, err)
16161616

1617-
assert.Assert(c, waitRun(name), check.IsNil)
1617+
assert.Assert(c, waitRun(name), checker.IsNil)
16181618

16191619
type b struct {
16201620
stats types.ContainerStats

integration-cli/docker_cli_attach_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
147147
stdout, err := cmd.StdoutPipe()
148148
assert.NilError(c, err)
149149
defer stdout.Close()
150-
assert.Assert(c, cmd.Start(), check.IsNil)
150+
assert.Assert(c, cmd.Start(), checker.IsNil)
151151
defer func() {
152152
cmd.Process.Kill()
153153
cmd.Wait()
@@ -157,13 +157,13 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
157157
assert.NilError(c, err)
158158
out, err = bufio.NewReader(stdout).ReadString('\n')
159159
assert.NilError(c, err)
160-
assert.Assert(c, strings.TrimSpace(out), check.Equals, "hello")
160+
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "hello")
161161

162-
assert.Assert(c, stdin.Close(), check.IsNil)
162+
assert.Assert(c, stdin.Close(), checker.IsNil)
163163

164164
// Expect container to still be running after stdin is closed
165165
running := inspectField(c, id, "State.Running")
166-
assert.Assert(c, running, check.Equals, "true")
166+
assert.Assert(c, running, checker.Equals, "true")
167167
}
168168

169169
func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) {

integration-cli/docker_cli_attach_unix_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) {
5151
case err := <-errChan:
5252
tty.Close()
5353
out, _ := ioutil.ReadAll(pty)
54-
assert.Assert(c, err, check.IsNil, check.Commentf("out: %v", string(out)))
54+
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", string(out)))
5555
case <-time.After(attachWait):
5656
c.Fatal("timed out without attach returning")
5757
}
@@ -74,7 +74,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) {
7474
close(cmdExit)
7575
}()
7676

77-
assert.Assert(c, waitRun(name), check.IsNil)
77+
assert.Assert(c, waitRun(name), checker.IsNil)
7878

7979
cpty.Write([]byte{16})
8080
time.Sleep(100 * time.Millisecond)

integration-cli/docker_cli_build_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4373,7 +4373,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *testing.T) {
43734373
)
43744374

43754375
res := inspectField(c, imgName, "Config.WorkingDir")
4376-
assert.Assert(c, filepath.ToSlash(res), check.Equals, filepath.ToSlash(wdVal))
4376+
assert.Assert(c, filepath.ToSlash(res), checker.Equals, filepath.ToSlash(wdVal))
43774377

43784378
var resArr []string
43794379
inspectFieldAndUnmarshall(c, imgName, "Config.Env", &resArr)
@@ -4754,7 +4754,7 @@ func (s *DockerSuite) TestBuildMultipleTags(c *testing.T) {
47544754

47554755
id1 := getIDByName(c, "tag1")
47564756
id2 := getIDByName(c, "tag2:v2")
4757-
assert.Assert(c, id1, check.Equals, id2)
4757+
assert.Assert(c, id1, checker.Equals, id2)
47584758
}
47594759

47604760
// #17290
@@ -5572,7 +5572,7 @@ func (s *DockerSuite) TestBuildNetContainer(c *testing.T) {
55725572
`))
55735573

55745574
host, _ := dockerCmd(c, "run", "testbuildnetcontainer", "cat", "/otherhost")
5575-
assert.Assert(c, strings.TrimSpace(host), check.Equals, "foobar")
5575+
assert.Assert(c, strings.TrimSpace(host), checker.Equals, "foobar")
55765576
}
55775577

55785578
func (s *DockerSuite) TestBuildWithExtraHost(c *testing.T) {
@@ -5777,9 +5777,9 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuilds(c *testing.T) {
57775777
cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
57785778

57795779
out := cli.DockerCmd(c, "run", "build2", "cat", "bar").Combined()
5780-
assert.Assert(c, strings.TrimSpace(out), check.Equals, "abc")
5780+
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "abc")
57815781
out = cli.DockerCmd(c, "run", "build2", "cat", "foo").Combined()
5782-
assert.Assert(c, strings.TrimSpace(out), check.Equals, "def")
5782+
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "def")
57835783
}
57845784

57855785
func (s *DockerSuite) TestBuildMultiStageImplicitFrom(c *testing.T) {
@@ -5893,9 +5893,9 @@ func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *testing.T) {
58935893
cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
58945894

58955895
out := cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\bar").Combined()
5896-
assert.Assert(c, strings.TrimSpace(out), check.Equals, "abc")
5896+
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "abc")
58975897
out = cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\foo").Combined()
5898-
assert.Assert(c, strings.TrimSpace(out), check.Equals, "def")
5898+
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "def")
58995899
}
59005900

59015901
func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) {
@@ -6223,5 +6223,5 @@ func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *testing.T) {
62236223
})
62246224
_, err = os.Stat(tmpIidFile)
62256225
assert.ErrorContains(c, err, "")
6226-
assert.Assert(c, os.IsNotExist(err), check.Equals, true)
6226+
assert.Assert(c, os.IsNotExist(err), checker.Equals, true)
62276227
}

integration-cli/docker_cli_build_unix_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
7676
err = json.Unmarshal([]byte(cfg), &c2)
7777
assert.Assert(c, err, checker.IsNil, check.Commentf(cfg))
7878

79-
assert.Assert(c, c2.Memory, check.Not(checker.Equals), int64(64*1024*1024), check.Commentf("resource leaked from build for Memory"))
80-
assert.Assert(c, c2.MemorySwap, check.Not(checker.Equals), int64(-1), check.Commentf("resource leaked from build for MemorySwap"))
81-
assert.Assert(c, c2.CpusetCpus, check.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetCpus"))
82-
assert.Assert(c, c2.CpusetMems, check.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetMems"))
83-
assert.Assert(c, c2.CPUShares, check.Not(checker.Equals), int64(100), check.Commentf("resource leaked from build for CPUShares"))
84-
assert.Assert(c, c2.CPUQuota, check.Not(checker.Equals), int64(8000), check.Commentf("resource leaked from build for CPUQuota"))
79+
assert.Assert(c, c2.Memory, checker.Not(checker.Equals), int64(64*1024*1024), check.Commentf("resource leaked from build for Memory"))
80+
assert.Assert(c, c2.MemorySwap, checker.Not(checker.Equals), int64(-1), check.Commentf("resource leaked from build for MemorySwap"))
81+
assert.Assert(c, c2.CpusetCpus, checker.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetCpus"))
82+
assert.Assert(c, c2.CpusetMems, checker.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetMems"))
83+
assert.Assert(c, c2.CPUShares, checker.Not(checker.Equals), int64(100), check.Commentf("resource leaked from build for CPUShares"))
84+
assert.Assert(c, c2.CPUQuota, checker.Not(checker.Equals), int64(8000), check.Commentf("resource leaked from build for CPUQuota"))
8585
assert.Assert(c, c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits"))
8686
}
8787

integration-cli/docker_cli_by_digest_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
389389

390390
func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) {
391391
digest, err := setupImage(c)
392-
assert.Assert(c, err, check.IsNil, check.Commentf("error setting up image"))
392+
assert.Assert(c, err, checker.IsNil, check.Commentf("error setting up image"))
393393

394394
imageReference := fmt.Sprintf("%s@%s", repoName, digest)
395395

@@ -556,7 +556,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
556556
// Pull from the registry using the <name>@<digest> reference.
557557
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
558558
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
559-
assert.Assert(c, exitStatus, checker.Not(check.Equals), 0)
559+
assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0)
560560

561561
expectedErrorMsg := fmt.Sprintf("manifest verification failed for digest %s", manifestDigest)
562562
assert.Assert(c, is.Contains(out, expectedErrorMsg))
@@ -598,7 +598,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing
598598
// Pull from the registry using the <name>@<digest> reference.
599599
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
600600
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
601-
assert.Assert(c, exitStatus, checker.Not(check.Equals), 0)
601+
assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0)
602602

603603
expectedErrorMsg := fmt.Sprintf("image verification failed for digest %s", manifestDigest)
604604
assert.Assert(c, out, checker.Contains, expectedErrorMsg)
@@ -641,7 +641,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
641641
// Pull from the registry using the <name>@<digest> reference.
642642
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
643643
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
644-
assert.Assert(c, exitStatus, checker.Not(check.Equals), 0, check.Commentf("expected a non-zero exit status"))
644+
assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0, check.Commentf("expected a non-zero exit status"))
645645

646646
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
647647
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)
684684
// Pull from the registry using the <name>@<digest> reference.
685685
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
686686
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
687-
assert.Assert(c, exitStatus, checker.Not(check.Equals), 0, check.Commentf("expected a non-zero exit status"))
687+
assert.Assert(c, exitStatus, checker.Not(checker.Equals), 0, check.Commentf("expected a non-zero exit status"))
688688

689689
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
690690
assert.Assert(c, out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out))

integration-cli/docker_cli_create_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) {
3737
}
3838

3939
err := json.Unmarshal([]byte(out), &containers)
40-
assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
40+
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
4141
assert.Equal(c, len(containers), 1)
4242

4343
cont := containers[0]
@@ -96,11 +96,11 @@ func (s *DockerSuite) TestCreateHostConfig(c *testing.T) {
9696
}
9797

9898
err := json.Unmarshal([]byte(out), &containers)
99-
assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
99+
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
100100
assert.Equal(c, len(containers), 1)
101101

102102
cont := containers[0]
103-
assert.Assert(c, cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
103+
assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none"))
104104
assert.Assert(c, cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false"))
105105
}
106106

@@ -117,12 +117,12 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) {
117117
}
118118
}
119119
err := json.Unmarshal([]byte(out), &containers)
120-
assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
120+
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
121121
assert.Equal(c, len(containers), 1)
122122

123123
cont := containers[0]
124124

125-
assert.Assert(c, cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
125+
assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none"))
126126
assert.Assert(c, cont.HostConfig.PortBindings, checker.HasLen, 4, check.Commentf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings)))
127127

128128
for k, v := range cont.HostConfig.PortBindings {
@@ -147,11 +147,11 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) {
147147
}
148148

149149
err := json.Unmarshal([]byte(out), &containers)
150-
assert.Assert(c, err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
150+
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
151151
assert.Equal(c, len(containers), 1)
152152

153153
cont := containers[0]
154-
assert.Assert(c, cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
154+
assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none"))
155155
assert.Assert(c, cont.HostConfig.PortBindings, checker.HasLen, 65535)
156156

157157
for k, v := range cont.HostConfig.PortBindings {
@@ -179,7 +179,7 @@ func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) {
179179
dockerCmd(c, "create", "--name", name, "-v", prefix+slash+"foo", "busybox")
180180

181181
dir, err := inspectMountSourceField(name, prefix+slash+"foo")
182-
assert.Assert(c, err, check.IsNil, check.Commentf("Error getting volume host path: %q", err))
182+
assert.Assert(c, err, checker.IsNil, check.Commentf("Error getting volume host path: %q", err))
183183

184184
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
185185
c.Fatalf("Volume was not created")
@@ -362,9 +362,9 @@ exec "$@"`,
362362

363363
out := cli.DockerCmd(c, "create", "--entrypoint=", name, "echo", "foo").Combined()
364364
id := strings.TrimSpace(out)
365-
assert.Assert(c, id, check.Not(check.Equals), "")
365+
assert.Assert(c, id, checker.Not(checker.Equals), "")
366366
out = cli.DockerCmd(c, "start", "-a", id).Combined()
367-
assert.Assert(c, strings.TrimSpace(out), check.Equals, "foo")
367+
assert.Assert(c, strings.TrimSpace(out), checker.Equals, "foo")
368368
}
369369

370370
// #22471

0 commit comments

Comments
 (0)