mirror of https://github.com/docker/compose.git
Also test running bash commands with `run /bin/sh -c …`, better test on slug label
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
8eb9733914
commit
1e6c4263cb
|
@ -115,6 +115,7 @@ func TestLocalComposeRun(t *testing.T) {
|
||||||
res := c.RunDockerCmd("ps", "--all")
|
res := c.RunDockerCmd("ps", "--all")
|
||||||
lines := Lines(res.Stdout())
|
lines := Lines(res.Stdout())
|
||||||
var runContainerID string
|
var runContainerID string
|
||||||
|
var truncatedSlug string
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
containerID := fields[len(fields)-1]
|
containerID := fields[len(fields)-1]
|
||||||
|
@ -122,6 +123,7 @@ func TestLocalComposeRun(t *testing.T) {
|
||||||
if strings.HasPrefix(containerID, "run-test_back") {
|
if strings.HasPrefix(containerID, "run-test_back") {
|
||||||
//only the one-off container for back service
|
//only the one-off container for back service
|
||||||
assert.Assert(t, strings.HasPrefix(containerID, "run-test_back_run_"), containerID)
|
assert.Assert(t, strings.HasPrefix(containerID, "run-test_back_run_"), containerID)
|
||||||
|
truncatedSlug = strings.Replace(containerID, "run-test_back_run_", "", 1)
|
||||||
runContainerID = containerID
|
runContainerID = containerID
|
||||||
assert.Assert(t, strings.Contains(line, "Exited"), line)
|
assert.Assert(t, strings.Contains(line, "Exited"), line)
|
||||||
}
|
}
|
||||||
|
@ -134,12 +136,13 @@ func TestLocalComposeRun(t *testing.T) {
|
||||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.container-number": "1"`})
|
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.container-number": "1"`})
|
||||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project": "run-test"`})
|
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project": "run-test"`})
|
||||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.oneoff": "True",`})
|
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.oneoff": "True",`})
|
||||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.slug": "`})
|
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.slug": "` + truncatedSlug})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("compose run --rm", func(t *testing.T) {
|
t.Run("compose run --rm", func(t *testing.T) {
|
||||||
res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "--rm", "back", "echo", "Hello again")
|
res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "--rm", "back", "/bin/sh", "-c", "echo Hello again")
|
||||||
res.Assert(t, icmd.Expected{Out: "Hello again"})
|
lines := Lines(res.Stdout())
|
||||||
|
assert.Equal(t, lines[len(lines)-1], "Hello again")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("check run container removed", func(t *testing.T) {
|
t.Run("check run container removed", func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue