(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestLocalComposeExecOneOff(t *testing.T) { |
| 70 | c := NewParallelCLI(t) |
| 71 | |
| 72 | const projectName = "compose-e2e-exec-one-off" |
| 73 | defer c.cleanupWithDown(t, projectName) |
| 74 | cmdArgs := func(cmd string, args ...string) []string { |
| 75 | ret := []string{"--project-directory", "fixtures/simple-composefile", "--project-name", projectName, cmd} |
| 76 | ret = append(ret, args...) |
| 77 | return ret |
| 78 | } |
| 79 | |
| 80 | c.RunDockerComposeCmd(t, cmdArgs("run", "-d", "simple")...) |
| 81 | |
| 82 | t.Run("exec in one-off container", func(t *testing.T) { |
| 83 | res := c.RunDockerComposeCmd(t, cmdArgs("exec", "-e", "FOO", "simple", "/usr/bin/env")...) |
| 84 | assert.Check(t, !strings.Contains(res.Stdout(), "FOO="), res.Combined()) |
| 85 | }) |
| 86 | |
| 87 | t.Run("exec with index", func(t *testing.T) { |
| 88 | res := c.RunDockerComposeCmdNoCheck(t, cmdArgs("exec", "--index", "1", "-e", "FOO", "simple", "/usr/bin/env")...) |
| 89 | res.Assert(t, icmd.Expected{ExitCode: 1, Err: "service \"simple\" is not running container #1"}) |
| 90 | }) |
| 91 | cmdResult := c.RunDockerCmd(t, "ps", "-q", "--filter", "label=com.docker.compose.project=compose-e2e-exec-one-off").Stdout() |
| 92 | containerIDs := strings.Split(cmdResult, "\n") |
| 93 | _ = c.RunDockerOrExitError(t, append([]string{"stop"}, containerIDs...)...) |
| 94 | } |
nothing calls this directly
no test coverage detected