Merge pull request #9566 from milas/e2e-ps-stdout

e2e: fix spurious `ps` failures
This commit is contained in:
Guillaume Lours 2022-06-16 18:07:22 +02:00 committed by GitHub
commit bec4ea4ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -22,6 +22,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/docker/compose/v2/pkg/api"
)
@ -41,7 +42,7 @@ func TestPs(t *testing.T) {
t.Run("pretty", func(t *testing.T) {
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/ps-test/compose.yaml", "--project-name", projectName, "ps")
lines := strings.Split(res.Combined(), "\n")
lines := strings.Split(res.Stdout(), "\n")
assert.Equal(t, 4, len(lines))
count := 0
for _, line := range lines[1:3] {
@ -61,8 +62,8 @@ func TestPs(t *testing.T) {
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/ps-test/compose.yaml", "--project-name", projectName, "ps",
"--format", "json")
var output []api.ContainerSummary
err := json.Unmarshal([]byte(res.Combined()), &output)
assert.NoError(t, err)
err := json.Unmarshal([]byte(res.Stdout()), &output)
require.NoError(t, err, "Failed to unmarshal ps JSON output")
count := 0
assert.Equal(t, 2, len(output))