Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"testing" |
| 9 | 9 |
|
| 10 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 10 | 11 |
"gotest.tools/v3/assert" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -24,7 +25,7 @@ func (s *DockerCLIInfoSuite) OnTimeout(c *testing.T) {
|
| 24 | 24 |
|
| 25 | 25 |
// ensure docker info succeeds |
| 26 | 26 |
func (s *DockerCLIInfoSuite) TestInfoEnsureSucceeds(c *testing.T) {
|
| 27 |
- out, _ := dockerCmd(c, "info") |
|
| 27 |
+ out := cli.DockerCmd(c, "info").Stdout() |
|
| 28 | 28 |
|
| 29 | 29 |
// always shown fields |
| 30 | 30 |
stringsToCheck := []string{
|
| ... | ... |
@@ -71,8 +72,8 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysRunningContainers(c *testing.T) {
|
| 71 | 71 |
|
| 72 | 72 |
existing := existingContainerStates(c) |
| 73 | 73 |
|
| 74 |
- dockerCmd(c, "run", "-d", "busybox", "top") |
|
| 75 |
- out, _ := dockerCmd(c, "info") |
|
| 74 |
+ cli.DockerCmd(c, "run", "-d", "busybox", "top") |
|
| 75 |
+ out := cli.DockerCmd(c, "info").Stdout() |
|
| 76 | 76 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
|
| 77 | 77 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1)))
|
| 78 | 78 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
|
| ... | ... |
@@ -84,12 +85,11 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysPausedContainers(c *testing.T) {
|
| 84 | 84 |
|
| 85 | 85 |
existing := existingContainerStates(c) |
| 86 | 86 |
|
| 87 |
- out := runSleepingContainer(c, "-d") |
|
| 88 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 87 |
+ id := runSleepingContainer(c, "-d") |
|
| 89 | 88 |
|
| 90 |
- dockerCmd(c, "pause", cleanedContainerID) |
|
| 89 |
+ cli.DockerCmd(c, "pause", id) |
|
| 91 | 90 |
|
| 92 |
- out, _ = dockerCmd(c, "info") |
|
| 91 |
+ out := cli.DockerCmd(c, "info").Stdout() |
|
| 93 | 92 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
|
| 94 | 93 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])))
|
| 95 | 94 |
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) {
|
| 101 | 101 |
|
| 102 | 102 |
existing := existingContainerStates(c) |
| 103 | 103 |
|
| 104 |
- out, _ := dockerCmd(c, "run", "-d", "busybox", "top") |
|
| 104 |
+ out := cli.DockerCmd(c, "run", "-d", "busybox", "top").Stdout() |
|
| 105 | 105 |
cleanedContainerID := strings.TrimSpace(out) |
| 106 | 106 |
|
| 107 |
- dockerCmd(c, "stop", cleanedContainerID) |
|
| 107 |
+ cli.DockerCmd(c, "stop", cleanedContainerID) |
|
| 108 | 108 |
|
| 109 |
- out, _ = dockerCmd(c, "info") |
|
| 109 |
+ out = cli.DockerCmd(c, "info").Stdout() |
|
| 110 | 110 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
|
| 111 | 111 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])))
|
| 112 | 112 |
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
|
| ... | ... |
@@ -114,7 +114,7 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
|
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 | 116 |
func existingContainerStates(c *testing.T) map[string]int {
|
| 117 |
- out, _ := dockerCmd(c, "info", "--format", "{{json .}}")
|
|
| 117 |
+ out := cli.DockerCmd(c, "info", "--format", "{{json .}}").Stdout()
|
|
| 118 | 118 |
var m map[string]interface{}
|
| 119 | 119 |
err := json.Unmarshal([]byte(out), &m) |
| 120 | 120 |
assert.NilError(c, err) |