mirror of https://github.com/docker/compose.git
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 <milas.bowman@docker.com>
This commit is contained in:
parent
9622395c8a
commit
3248b7b335
|
@ -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())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue