From 3248b7b33555e09faca4b98fdbb11e0841486424 Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Thu, 16 Jun 2022 16:42:49 -0400 Subject: [PATCH] e2e: use Compose for exec test This was using `docker exec` on Compose containers instead of `docker compose exec` (and `docker-compose exec` for standalone). Thanks to @glours for catching! Signed-off-by: Milas Bowman --- pkg/e2e/compose_exec_test.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/e2e/compose_exec_test.go b/pkg/e2e/compose_exec_test.go index c6844d338..26885f283 100644 --- a/pkg/e2e/compose_exec_test.go +++ b/pkg/e2e/compose_exec_test.go @@ -29,21 +29,25 @@ func TestLocalComposeExec(t *testing.T) { const projectName = "compose-e2e-exec" - c.RunDockerComposeCmd(t, "--project-directory", "fixtures/simple-composefile", "--project-name", projectName, "up", - "-d") + cmdArgs := func(cmd string, args ...string) []string { + ret := []string{"--project-directory", "fixtures/simple-composefile", "--project-name", projectName, cmd} + ret = append(ret, args...) + return ret + } + + c.RunDockerComposeCmd(t, cmdArgs("up", "-d")...) t.Run("exec true", func(t *testing.T) { - res := c.RunDockerOrExitError(t, "exec", "compose-e2e-exec-simple-1", "/bin/true") - res.Assert(t, icmd.Expected{ExitCode: 0}) + c.RunDockerComposeCmd(t, cmdArgs("exec", "simple", "/bin/true")...) }) t.Run("exec false", func(t *testing.T) { - res := c.RunDockerOrExitError(t, "exec", "compose-e2e-exec-simple-1", "/bin/false") + res := c.RunDockerComposeCmdNoCheck(t, cmdArgs("exec", "simple", "/bin/false")...) res.Assert(t, icmd.Expected{ExitCode: 1}) }) t.Run("exec with env set", func(t *testing.T) { - res := icmd.RunCmd(c.NewDockerCmd(t, "exec", "-e", "FOO", "compose-e2e-exec-simple-1", "/usr/bin/env"), + res := icmd.RunCmd(c.NewDockerComposeCmd(t, cmdArgs("exec", "-e", "FOO", "simple", "/usr/bin/env")...), func(cmd *icmd.Cmd) { cmd.Env = append(cmd.Env, "FOO=BAR") }) @@ -51,8 +55,7 @@ func TestLocalComposeExec(t *testing.T) { }) t.Run("exec without env set", func(t *testing.T) { - res := c.RunDockerOrExitError(t, "exec", "-e", "FOO", "compose-e2e-exec-simple-1", "/usr/bin/env") - res.Assert(t, icmd.Expected{ExitCode: 0}) - assert.Check(t, !strings.Contains(res.Stdout(), "FOO=")) + res := c.RunDockerComposeCmd(t, cmdArgs("exec", "-e", "FOO", "simple", "/usr/bin/env")...) + assert.Check(t, !strings.Contains(res.Stdout(), "FOO="), res.Combined()) }) }