Ver Fonte

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn há 2 anos atrás
pai
commit
6331a3a346

+ 1 - 1
integration-cli/check_test.go

@@ -76,7 +76,7 @@ func printCliVersion() {
 	cli.SetTestEnvironment(testEnv)
 	cmd := cli.Docker(cli.Args("version"))
 	if cmd.Error != nil {
-		fmt.Printf("WARNING: Failed to run \"docker version\": %+v\n", cmd.Error)
+		fmt.Printf("WARNING: Failed to run 'docker version': %+v\n", cmd.Error)
 		return
 	}
 

+ 1 - 1
integration-cli/docker_api_containers_test.go

@@ -1158,7 +1158,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
 	assert.Assert(c, waitRun(id2) == nil)
 
 	links := inspectFieldJSON(c, id2, "HostConfig.Links")
-	assert.Equal(c, links, "[\"/tlink1:/tlink2/tlink1\"]", "expected to have links between containers")
+	assert.Equal(c, links, `["/tlink1:/tlink2/tlink1"]`, "expected to have links between containers")
 
 	removeOptions := types.ContainerRemoveOptions{
 		RemoveLinks: true,

+ 2 - 2
integration-cli/docker_cli_build_test.go

@@ -2258,7 +2258,7 @@ docker.com>"
   `))
 
 	res := inspectField(c, name, "Author")
-	if res != "\"Docker IO <io@docker.com>\"" {
+	if res != `"Docker IO <io@docker.com>"` {
 		c.Fatalf("Parsed string did not match the escaped string. Got: %q", res)
 	}
 }
@@ -2272,7 +2272,7 @@ func (s *DockerCLIBuildSuite) TestBuildVerifyIntString(c *testing.T) {
 	MAINTAINER 123`))
 
 	out, _ := dockerCmd(c, "inspect", name)
-	if !strings.Contains(out, "\"123\"") {
+	if !strings.Contains(out, `"123"`) {
 		c.Fatalf("Output does not contain the int as a string:\n%s", out)
 	}
 }

+ 11 - 11
integration-cli/docker_cli_commit_test.go

@@ -120,17 +120,17 @@ func (s *DockerCLICommitSuite) TestCommitChange(c *testing.T) {
 	dockerCmd(c, "run", "--name", "test", "busybox", "true")
 
 	imageID, _ := dockerCmd(c, "commit",
-		"--change", "EXPOSE 8080",
-		"--change", "ENV DEBUG true",
-		"--change", "ENV test 1",
-		"--change", "ENV PATH /foo",
-		"--change", "LABEL foo bar",
-		"--change", "CMD [\"/bin/sh\"]",
-		"--change", "WORKDIR /opt",
-		"--change", "ENTRYPOINT [\"/bin/sh\"]",
-		"--change", "USER testuser",
-		"--change", "VOLUME /var/lib/docker",
-		"--change", "ONBUILD /usr/local/bin/python-build --dir /app/src",
+		"--change", `EXPOSE 8080`,
+		"--change", `ENV DEBUG true`,
+		"--change", `ENV test 1`,
+		"--change", `ENV PATH /foo`,
+		"--change", `LABEL foo bar`,
+		"--change", `CMD ["/bin/sh"]`,
+		"--change", `WORKDIR /opt`,
+		"--change", `ENTRYPOINT ["/bin/sh"]`,
+		"--change", `USER testuser`,
+		"--change", `VOLUME /var/lib/docker`,
+		"--change", `ONBUILD /usr/local/bin/python-build --dir /app/src`,
 		"test", "test-commit")
 	imageID = strings.TrimSpace(imageID)
 

+ 2 - 2
integration-cli/docker_cli_events_test.go

@@ -750,7 +750,7 @@ func (s *DockerCLIEventSuite) TestEventsFormatBadFunc(c *testing.T) {
 	result.Assert(c, icmd.Expected{
 		Error:    "exit status 64",
 		ExitCode: 64,
-		Err:      "Error parsing format: template: :1: function \"badFuncString\" not defined",
+		Err:      `Error parsing format: template: :1: function "badFuncString" not defined`,
 	})
 }
 
@@ -760,6 +760,6 @@ func (s *DockerCLIEventSuite) TestEventsFormatBadField(c *testing.T) {
 	result.Assert(c, icmd.Expected{
 		Error:    "exit status 64",
 		ExitCode: 64,
-		Err:      "Error parsing format: template: :1:2: executing \"\" at <.badFieldString>: can't evaluate field badFieldString in type *events.Message",
+		Err:      `Error parsing format: template: :1:2: executing "" at <.badFieldString>: can't evaluate field badFieldString in type *events.Message`,
 	})
 }

+ 15 - 15
integration-cli/docker_cli_events_unix_test.go

@@ -414,21 +414,21 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *testing.T) {
 	// only check for values known (daemon ID/name) or explicitly set above,
 	// otherwise just check for names being present.
 	expectedSubstrings := []string{
-		" daemon reload " + info.ID + " ",
-		"(allow-nondistributable-artifacts=[",
-		" debug=true, ",
-		" default-ipc-mode=",
-		" default-runtime=",
-		" default-shm-size=",
-		" insecure-registries=[",
-		" labels=[\"bar=foo\"], ",
-		" live-restore=",
-		" max-concurrent-downloads=1, ",
-		" max-concurrent-uploads=5, ",
-		" name=" + info.Name,
-		" registry-mirrors=[",
-		" runtimes=",
-		" shutdown-timeout=10)",
+		` daemon reload ` + info.ID + " ",
+		`(allow-nondistributable-artifacts=[`,
+		` debug=true, `,
+		` default-ipc-mode=`,
+		` default-runtime=`,
+		` default-shm-size=`,
+		` insecure-registries=[`,
+		` labels=["bar=foo"], `,
+		` live-restore=`,
+		` max-concurrent-downloads=1, `,
+		` max-concurrent-uploads=5, `,
+		` name=` + info.Name,
+		` registry-mirrors=[`,
+		` runtimes=`,
+		` shutdown-timeout=10)`,
 	}
 
 	for _, s := range expectedSubstrings {

+ 1 - 1
integration-cli/docker_cli_links_test.go

@@ -218,7 +218,7 @@ func (s *DockerCLILinksSuite) TestLinkShortDefinition(c *testing.T) {
 	assert.Assert(c, waitRun(cid2) == nil)
 
 	links := inspectFieldJSON(c, cid2, "HostConfig.Links")
-	assert.Equal(c, links, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
+	assert.Equal(c, links, `["/shortlinkdef:/link2/shortlinkdef"]`)
 }
 
 func (s *DockerCLILinksSuite) TestLinksNetworkHostContainer(c *testing.T) {

+ 3 - 3
integration-cli/docker_cli_ps_test.go

@@ -176,7 +176,7 @@ func (s *DockerCLIPsSuite) TestPsListContainersSize(c *testing.T) {
 	select {
 	case <-wait:
 	case <-time.After(3 * time.Second):
-		c.Fatalf("Calling \"docker ps -s\" timed out!")
+		c.Fatalf(`Calling "docker ps -s" timed out!`)
 	}
 	result.Assert(c, icmd.Success)
 	lines := strings.Split(strings.Trim(result.Combined(), "\n "), "\n")
@@ -634,8 +634,8 @@ func (s *DockerCLIPsSuite) TestPsShowMounts(c *testing.T) {
 	var bindMountSource string
 	var bindMountDestination string
 	if DaemonIsWindows() {
-		bindMountSource = "c:\\"
-		bindMountDestination = "c:\\t"
+		bindMountSource = `c:\`
+		bindMountDestination = `c:\t`
 	} else {
 		bindMountSource = "/tmp"
 		bindMountDestination = "/t"

+ 2 - 2
integration-cli/docker_cli_pull_local_test.go

@@ -391,7 +391,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithSchem
 
 	b, err := os.ReadFile(configPath)
 	assert.NilError(c, err)
-	assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
+	assert.Assert(c, !strings.Contains(string(b), `"auth":`))
 	dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
 	dockerCmd(c, "--config", tmp, "push", repoName)
 
@@ -433,7 +433,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *testing.T)
 
 	b, err := os.ReadFile(configPath)
 	assert.NilError(c, err)
-	assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
+	assert.Assert(c, !strings.Contains(string(b), `"auth":`))
 	dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
 	dockerCmd(c, "--config", tmp, "push", repoName)
 

+ 2 - 2
integration-cli/docker_cli_run_test.go

@@ -1673,7 +1673,7 @@ func (s *DockerCLIRunSuite) TestRunCopyVolumeUIDGID(c *testing.T) {
 		RUN mkdir -p /hello && touch /hello/test && chown dockerio.dockerio /hello`))
 
 	// Test that the uid and gid is copied from the image to the volume
-	out, _ := dockerCmd(c, "run", "--rm", "-v", "/hello", name, "sh", "-c", "ls -l / | grep hello | awk '{print $3\":\"$4}'")
+	out, _ := dockerCmd(c, "run", "--rm", "-v", "/hello", name, "sh", "-c", `ls -l / | grep hello | awk '{print $3":"$4}'`)
 	out = strings.TrimSpace(out)
 	if out != "dockerio:dockerio" {
 		c.Fatalf("Wrong /hello ownership: %s, expected dockerio:dockerio", out)
@@ -2053,7 +2053,7 @@ func (s *DockerCLIRunSuite) TestRunPortInUse(c *testing.T) {
 		c.Fatalf("Binding on used port must fail")
 	}
 	if !strings.Contains(out, "port is already allocated") {
-		c.Fatalf("Out must be about \"port is already allocated\", got %s", out)
+		c.Fatalf(`Out must be about "port is already allocated", got %s`, out)
 	}
 }
 

+ 2 - 2
integration-cli/docker_cli_service_logs_test.go

@@ -229,7 +229,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTaskLogs(c *testing.T) {
 	assert.Assert(c, id != "")
 	// so, right here, we're basically inspecting by id and returning only
 	// the ID. if they don't match, the service doesn't exist.
-	result = icmd.RunCmd(d.Command("service", "inspect", "--format=\"{{.ID}}\"", id))
+	result = icmd.RunCmd(d.Command("service", "inspect", `--format="{{.ID}}"`, id))
 	result.Assert(c, icmd.Expected{Out: id})
 
 	// make sure task has been deployed.
@@ -282,7 +282,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTTY(c *testing.T) {
 	assert.Assert(c, id != "")
 	// so, right here, we're basically inspecting by id and returning only
 	// the ID. if they don't match, the service doesn't exist.
-	result = icmd.RunCmd(d.Command("service", "inspect", "--format=\"{{.ID}}\"", id))
+	result = icmd.RunCmd(d.Command("service", "inspect", `--format="{{.ID}}"`, id))
 	result.Assert(c, icmd.Expected{Out: id})
 
 	// make sure task has been deployed.