From 152c2d9a33f21991e40659f4218b6d780fe24044 Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Thu, 16 Jun 2022 10:04:23 -0400 Subject: [PATCH] e2e: fix spurious `ps` failures Use the command `stdout` instead of combined `stdout` + `stderr` for assertions to avoid failures from any CLI logging such as warnings, which will be on `stderr`. Signed-off-by: Milas Bowman --- pkg/e2e/ps_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/e2e/ps_test.go b/pkg/e2e/ps_test.go index dfa025d883..0428921144 100644 --- a/pkg/e2e/ps_test.go +++ b/pkg/e2e/ps_test.go @@ -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))