From 6331a3a3465b4c3d97bfefc3faa6ea68d59f391c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 5 Jul 2023 12:12:16 +0200 Subject: [PATCH] integration-cli: use string-literals for easier grep'ing Signed-off-by: Sebastiaan van Stijn --- integration-cli/check_test.go | 2 +- integration-cli/docker_api_containers_test.go | 2 +- integration-cli/docker_cli_build_test.go | 4 +-- integration-cli/docker_cli_commit_test.go | 22 +++++++------- integration-cli/docker_cli_events_test.go | 4 +-- .../docker_cli_events_unix_test.go | 30 +++++++++---------- integration-cli/docker_cli_links_test.go | 2 +- integration-cli/docker_cli_ps_test.go | 6 ++-- integration-cli/docker_cli_pull_local_test.go | 4 +-- integration-cli/docker_cli_run_test.go | 4 +-- .../docker_cli_service_logs_test.go | 4 +-- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go index 4cc7f37f04..af321bf07c 100644 --- a/integration-cli/check_test.go +++ b/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 } diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 245dc2b835..f61f611109 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/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, diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 7e81df4e70..f87713caa0 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -2258,7 +2258,7 @@ docker.com>" `)) res := inspectField(c, name, "Author") - if res != "\"Docker IO \"" { + if res != `"Docker IO "` { 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) } } diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go index 97655aa518..e46d4f35e7 100644 --- a/integration-cli/docker_cli_commit_test.go +++ b/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) diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index 449b06a7a6..dea0301c28 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/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`, }) } diff --git a/integration-cli/docker_cli_events_unix_test.go b/integration-cli/docker_cli_events_unix_test.go index 5a5b44636d..b93a1d603e 100644 --- a/integration-cli/docker_cli_events_unix_test.go +++ b/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 { diff --git a/integration-cli/docker_cli_links_test.go b/integration-cli/docker_cli_links_test.go index 4ed2d6c592..5d1f9e7fa1 100644 --- a/integration-cli/docker_cli_links_test.go +++ b/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) { diff --git a/integration-cli/docker_cli_ps_test.go b/integration-cli/docker_cli_ps_test.go index 693cde7de5..b5ae77286f 100644 --- a/integration-cli/docker_cli_ps_test.go +++ b/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" diff --git a/integration-cli/docker_cli_pull_local_test.go b/integration-cli/docker_cli_pull_local_test.go index 59dc27e00d..7ada4a7e44 100644 --- a/integration-cli/docker_cli_pull_local_test.go +++ b/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) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index ad576778de..e49739b55c 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/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) } } diff --git a/integration-cli/docker_cli_service_logs_test.go b/integration-cli/docker_cli_service_logs_test.go index aa5a0618cb..7e3b52b0c7 100644 --- a/integration-cli/docker_cli_service_logs_test.go +++ b/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.