integration-cli: DockerCLIInfoSuite: replace dockerCmd and waitRun
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
4562f07887
commit
ba32bebd05
1 changed files with 11 additions and 11 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/docker/integration-cli/cli"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ func (s *DockerCLIInfoSuite) OnTimeout(c *testing.T) {
|
||||||
|
|
||||||
// ensure docker info succeeds
|
// ensure docker info succeeds
|
||||||
func (s *DockerCLIInfoSuite) TestInfoEnsureSucceeds(c *testing.T) {
|
func (s *DockerCLIInfoSuite) TestInfoEnsureSucceeds(c *testing.T) {
|
||||||
out, _ := dockerCmd(c, "info")
|
out := cli.DockerCmd(c, "info").Stdout()
|
||||||
|
|
||||||
// always shown fields
|
// always shown fields
|
||||||
stringsToCheck := []string{
|
stringsToCheck := []string{
|
||||||
|
@ -71,8 +72,8 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysRunningContainers(c *testing.T) {
|
||||||
|
|
||||||
existing := existingContainerStates(c)
|
existing := existingContainerStates(c)
|
||||||
|
|
||||||
dockerCmd(c, "run", "-d", "busybox", "top")
|
cli.DockerCmd(c, "run", "-d", "busybox", "top")
|
||||||
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("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(" Running: %d\n", existing["ContainersRunning"]+1)))
|
||||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
|
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)
|
existing := existingContainerStates(c)
|
||||||
|
|
||||||
out := runSleepingContainer(c, "-d")
|
id := runSleepingContainer(c, "-d")
|
||||||
cleanedContainerID := strings.TrimSpace(out)
|
|
||||||
|
|
||||||
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("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(" Running: %d\n", existing["ContainersRunning"])))
|
||||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1)))
|
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)
|
existing := existingContainerStates(c)
|
||||||
|
|
||||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
out := cli.DockerCmd(c, "run", "-d", "busybox", "top").Stdout()
|
||||||
cleanedContainerID := strings.TrimSpace(out)
|
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("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(" Running: %d\n", existing["ContainersRunning"])))
|
||||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
|
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 {
|
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{}
|
var m map[string]interface{}
|
||||||
err := json.Unmarshal([]byte(out), &m)
|
err := json.Unmarshal([]byte(out), &m)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
Loading…
Reference in a new issue