Browse code

integration-cli: use string-literals for easier grep'ing

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/07/05 19:12:16
Showing 11 changed files
... ...
@@ -76,7 +76,7 @@ func printCliVersion() {
76 76
 	cli.SetTestEnvironment(testEnv)
77 77
 	cmd := cli.Docker(cli.Args("version"))
78 78
 	if cmd.Error != nil {
79
-		fmt.Printf("WARNING: Failed to run \"docker version\": %+v\n", cmd.Error)
79
+		fmt.Printf("WARNING: Failed to run 'docker version': %+v\n", cmd.Error)
80 80
 		return
81 81
 	}
82 82
 
... ...
@@ -1158,7 +1158,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
1158 1158
 	assert.Assert(c, waitRun(id2) == nil)
1159 1159
 
1160 1160
 	links := inspectFieldJSON(c, id2, "HostConfig.Links")
1161
-	assert.Equal(c, links, "[\"/tlink1:/tlink2/tlink1\"]", "expected to have links between containers")
1161
+	assert.Equal(c, links, `["/tlink1:/tlink2/tlink1"]`, "expected to have links between containers")
1162 1162
 
1163 1163
 	removeOptions := types.ContainerRemoveOptions{
1164 1164
 		RemoveLinks: true,
... ...
@@ -2258,7 +2258,7 @@ docker.com>"
2258 2258
   `))
2259 2259
 
2260 2260
 	res := inspectField(c, name, "Author")
2261
-	if res != "\"Docker IO <io@docker.com>\"" {
2261
+	if res != `"Docker IO <io@docker.com>"` {
2262 2262
 		c.Fatalf("Parsed string did not match the escaped string. Got: %q", res)
2263 2263
 	}
2264 2264
 }
... ...
@@ -2272,7 +2272,7 @@ func (s *DockerCLIBuildSuite) TestBuildVerifyIntString(c *testing.T) {
2272 2272
 	MAINTAINER 123`))
2273 2273
 
2274 2274
 	out, _ := dockerCmd(c, "inspect", name)
2275
-	if !strings.Contains(out, "\"123\"") {
2275
+	if !strings.Contains(out, `"123"`) {
2276 2276
 		c.Fatalf("Output does not contain the int as a string:\n%s", out)
2277 2277
 	}
2278 2278
 }
... ...
@@ -120,17 +120,17 @@ func (s *DockerCLICommitSuite) TestCommitChange(c *testing.T) {
120 120
 	dockerCmd(c, "run", "--name", "test", "busybox", "true")
121 121
 
122 122
 	imageID, _ := dockerCmd(c, "commit",
123
-		"--change", "EXPOSE 8080",
124
-		"--change", "ENV DEBUG true",
125
-		"--change", "ENV test 1",
126
-		"--change", "ENV PATH /foo",
127
-		"--change", "LABEL foo bar",
128
-		"--change", "CMD [\"/bin/sh\"]",
129
-		"--change", "WORKDIR /opt",
130
-		"--change", "ENTRYPOINT [\"/bin/sh\"]",
131
-		"--change", "USER testuser",
132
-		"--change", "VOLUME /var/lib/docker",
133
-		"--change", "ONBUILD /usr/local/bin/python-build --dir /app/src",
123
+		"--change", `EXPOSE 8080`,
124
+		"--change", `ENV DEBUG true`,
125
+		"--change", `ENV test 1`,
126
+		"--change", `ENV PATH /foo`,
127
+		"--change", `LABEL foo bar`,
128
+		"--change", `CMD ["/bin/sh"]`,
129
+		"--change", `WORKDIR /opt`,
130
+		"--change", `ENTRYPOINT ["/bin/sh"]`,
131
+		"--change", `USER testuser`,
132
+		"--change", `VOLUME /var/lib/docker`,
133
+		"--change", `ONBUILD /usr/local/bin/python-build --dir /app/src`,
134 134
 		"test", "test-commit")
135 135
 	imageID = strings.TrimSpace(imageID)
136 136
 
... ...
@@ -750,7 +750,7 @@ func (s *DockerCLIEventSuite) TestEventsFormatBadFunc(c *testing.T) {
750 750
 	result.Assert(c, icmd.Expected{
751 751
 		Error:    "exit status 64",
752 752
 		ExitCode: 64,
753
-		Err:      "Error parsing format: template: :1: function \"badFuncString\" not defined",
753
+		Err:      `Error parsing format: template: :1: function "badFuncString" not defined`,
754 754
 	})
755 755
 }
756 756
 
... ...
@@ -760,6 +760,6 @@ func (s *DockerCLIEventSuite) TestEventsFormatBadField(c *testing.T) {
760 760
 	result.Assert(c, icmd.Expected{
761 761
 		Error:    "exit status 64",
762 762
 		ExitCode: 64,
763
-		Err:      "Error parsing format: template: :1:2: executing \"\" at <.badFieldString>: can't evaluate field badFieldString in type *events.Message",
763
+		Err:      `Error parsing format: template: :1:2: executing "" at <.badFieldString>: can't evaluate field badFieldString in type *events.Message`,
764 764
 	})
765 765
 }
... ...
@@ -414,21 +414,21 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *testing.T) {
414 414
 	// only check for values known (daemon ID/name) or explicitly set above,
415 415
 	// otherwise just check for names being present.
416 416
 	expectedSubstrings := []string{
417
-		" daemon reload " + info.ID + " ",
418
-		"(allow-nondistributable-artifacts=[",
419
-		" debug=true, ",
420
-		" default-ipc-mode=",
421
-		" default-runtime=",
422
-		" default-shm-size=",
423
-		" insecure-registries=[",
424
-		" labels=[\"bar=foo\"], ",
425
-		" live-restore=",
426
-		" max-concurrent-downloads=1, ",
427
-		" max-concurrent-uploads=5, ",
428
-		" name=" + info.Name,
429
-		" registry-mirrors=[",
430
-		" runtimes=",
431
-		" shutdown-timeout=10)",
417
+		` daemon reload ` + info.ID + " ",
418
+		`(allow-nondistributable-artifacts=[`,
419
+		` debug=true, `,
420
+		` default-ipc-mode=`,
421
+		` default-runtime=`,
422
+		` default-shm-size=`,
423
+		` insecure-registries=[`,
424
+		` labels=["bar=foo"], `,
425
+		` live-restore=`,
426
+		` max-concurrent-downloads=1, `,
427
+		` max-concurrent-uploads=5, `,
428
+		` name=` + info.Name,
429
+		` registry-mirrors=[`,
430
+		` runtimes=`,
431
+		` shutdown-timeout=10)`,
432 432
 	}
433 433
 
434 434
 	for _, s := range expectedSubstrings {
... ...
@@ -218,7 +218,7 @@ func (s *DockerCLILinksSuite) TestLinkShortDefinition(c *testing.T) {
218 218
 	assert.Assert(c, waitRun(cid2) == nil)
219 219
 
220 220
 	links := inspectFieldJSON(c, cid2, "HostConfig.Links")
221
-	assert.Equal(c, links, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
221
+	assert.Equal(c, links, `["/shortlinkdef:/link2/shortlinkdef"]`)
222 222
 }
223 223
 
224 224
 func (s *DockerCLILinksSuite) TestLinksNetworkHostContainer(c *testing.T) {
... ...
@@ -176,7 +176,7 @@ func (s *DockerCLIPsSuite) TestPsListContainersSize(c *testing.T) {
176 176
 	select {
177 177
 	case <-wait:
178 178
 	case <-time.After(3 * time.Second):
179
-		c.Fatalf("Calling \"docker ps -s\" timed out!")
179
+		c.Fatalf(`Calling "docker ps -s" timed out!`)
180 180
 	}
181 181
 	result.Assert(c, icmd.Success)
182 182
 	lines := strings.Split(strings.Trim(result.Combined(), "\n "), "\n")
... ...
@@ -634,8 +634,8 @@ func (s *DockerCLIPsSuite) TestPsShowMounts(c *testing.T) {
634 634
 	var bindMountSource string
635 635
 	var bindMountDestination string
636 636
 	if DaemonIsWindows() {
637
-		bindMountSource = "c:\\"
638
-		bindMountDestination = "c:\\t"
637
+		bindMountSource = `c:\`
638
+		bindMountDestination = `c:\t`
639 639
 	} else {
640 640
 		bindMountSource = "/tmp"
641 641
 		bindMountDestination = "/t"
... ...
@@ -391,7 +391,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithSchem
391 391
 
392 392
 	b, err := os.ReadFile(configPath)
393 393
 	assert.NilError(c, err)
394
-	assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
394
+	assert.Assert(c, !strings.Contains(string(b), `"auth":`))
395 395
 	dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
396 396
 	dockerCmd(c, "--config", tmp, "push", repoName)
397 397
 
... ...
@@ -433,7 +433,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *testing.T)
433 433
 
434 434
 	b, err := os.ReadFile(configPath)
435 435
 	assert.NilError(c, err)
436
-	assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
436
+	assert.Assert(c, !strings.Contains(string(b), `"auth":`))
437 437
 	dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
438 438
 	dockerCmd(c, "--config", tmp, "push", repoName)
439 439
 
... ...
@@ -1673,7 +1673,7 @@ func (s *DockerCLIRunSuite) TestRunCopyVolumeUIDGID(c *testing.T) {
1673 1673
 		RUN mkdir -p /hello && touch /hello/test && chown dockerio.dockerio /hello`))
1674 1674
 
1675 1675
 	// Test that the uid and gid is copied from the image to the volume
1676
-	out, _ := dockerCmd(c, "run", "--rm", "-v", "/hello", name, "sh", "-c", "ls -l / | grep hello | awk '{print $3\":\"$4}'")
1676
+	out, _ := dockerCmd(c, "run", "--rm", "-v", "/hello", name, "sh", "-c", `ls -l / | grep hello | awk '{print $3":"$4}'`)
1677 1677
 	out = strings.TrimSpace(out)
1678 1678
 	if out != "dockerio:dockerio" {
1679 1679
 		c.Fatalf("Wrong /hello ownership: %s, expected dockerio:dockerio", out)
... ...
@@ -2053,7 +2053,7 @@ func (s *DockerCLIRunSuite) TestRunPortInUse(c *testing.T) {
2053 2053
 		c.Fatalf("Binding on used port must fail")
2054 2054
 	}
2055 2055
 	if !strings.Contains(out, "port is already allocated") {
2056
-		c.Fatalf("Out must be about \"port is already allocated\", got %s", out)
2056
+		c.Fatalf(`Out must be about "port is already allocated", got %s`, out)
2057 2057
 	}
2058 2058
 }
2059 2059
 
... ...
@@ -229,7 +229,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTaskLogs(c *testing.T) {
229 229
 	assert.Assert(c, id != "")
230 230
 	// so, right here, we're basically inspecting by id and returning only
231 231
 	// the ID. if they don't match, the service doesn't exist.
232
-	result = icmd.RunCmd(d.Command("service", "inspect", "--format=\"{{.ID}}\"", id))
232
+	result = icmd.RunCmd(d.Command("service", "inspect", `--format="{{.ID}}"`, id))
233 233
 	result.Assert(c, icmd.Expected{Out: id})
234 234
 
235 235
 	// make sure task has been deployed.
... ...
@@ -282,7 +282,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTTY(c *testing.T) {
282 282
 	assert.Assert(c, id != "")
283 283
 	// so, right here, we're basically inspecting by id and returning only
284 284
 	// the ID. if they don't match, the service doesn't exist.
285
-	result = icmd.RunCmd(d.Command("service", "inspect", "--format=\"{{.ID}}\"", id))
285
+	result = icmd.RunCmd(d.Command("service", "inspect", `--format="{{.ID}}"`, id))
286 286
 	result.Assert(c, icmd.Expected{Out: id})
287 287
 
288 288
 	// make sure task has been deployed.