From ba32bebd0540c04e30ada06db21266e2cc696dac Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 27 Jul 2023 13:35:46 +0200 Subject: [PATCH] integration-cli: DockerCLIInfoSuite: replace dockerCmd and waitRun Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_cli_info_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/integration-cli/docker_cli_info_test.go b/integration-cli/docker_cli_info_test.go index 4c95d134ff..e22f2a2570 100644 --- a/integration-cli/docker_cli_info_test.go +++ b/integration-cli/docker_cli_info_test.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + "github.com/docker/docker/integration-cli/cli" "gotest.tools/v3/assert" ) @@ -24,7 +25,7 @@ func (s *DockerCLIInfoSuite) OnTimeout(c *testing.T) { // ensure docker info succeeds func (s *DockerCLIInfoSuite) TestInfoEnsureSucceeds(c *testing.T) { - out, _ := dockerCmd(c, "info") + out := cli.DockerCmd(c, "info").Stdout() // always shown fields stringsToCheck := []string{ @@ -71,8 +72,8 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysRunningContainers(c *testing.T) { existing := existingContainerStates(c) - dockerCmd(c, "run", "-d", "busybox", "top") - out, _ := dockerCmd(c, "info") + cli.DockerCmd(c, "run", "-d", "busybox", "top") + out := cli.DockerCmd(c, "info").Stdout() assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))) assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1))) assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]))) @@ -84,12 +85,11 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysPausedContainers(c *testing.T) { existing := existingContainerStates(c) - out := runSleepingContainer(c, "-d") - cleanedContainerID := strings.TrimSpace(out) + id := runSleepingContainer(c, "-d") - dockerCmd(c, "pause", cleanedContainerID) + cli.DockerCmd(c, "pause", id) - out, _ = dockerCmd(c, "info") + out := cli.DockerCmd(c, "info").Stdout() assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))) assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]))) assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1))) @@ -101,12 +101,12 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysStoppedContainers(c *testing.T) { existing := existingContainerStates(c) - out, _ := dockerCmd(c, "run", "-d", "busybox", "top") + out := cli.DockerCmd(c, "run", "-d", "busybox", "top").Stdout() cleanedContainerID := strings.TrimSpace(out) - dockerCmd(c, "stop", cleanedContainerID) + cli.DockerCmd(c, "stop", cleanedContainerID) - out, _ = dockerCmd(c, "info") + out = cli.DockerCmd(c, "info").Stdout() assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))) assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]))) assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]))) @@ -114,7 +114,7 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysStoppedContainers(c *testing.T) { } func existingContainerStates(c *testing.T) map[string]int { - out, _ := dockerCmd(c, "info", "--format", "{{json .}}") + out := cli.DockerCmd(c, "info", "--format", "{{json .}}").Stdout() var m map[string]interface{} err := json.Unmarshal([]byte(out), &m) assert.NilError(c, err)