From 1e6c4263cba348a1a5498fd73058e4e609ee715c Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 14 Dec 2020 18:31:35 +0100 Subject: [PATCH] =?UTF-8?q?Also=20test=20running=20bash=20commands=20with?= =?UTF-8?q?=20`run=20/bin/sh=20-c=20=E2=80=A6`,=20better=20test=20on=20slu?= =?UTF-8?q?g=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- tests/compose-e2e/compose_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/compose-e2e/compose_test.go b/tests/compose-e2e/compose_test.go index 8240fdb3d..8ef6e9d4c 100644 --- a/tests/compose-e2e/compose_test.go +++ b/tests/compose-e2e/compose_test.go @@ -115,6 +115,7 @@ func TestLocalComposeRun(t *testing.T) { res := c.RunDockerCmd("ps", "--all") lines := Lines(res.Stdout()) var runContainerID string + var truncatedSlug string for _, line := range lines { fields := strings.Fields(line) containerID := fields[len(fields)-1] @@ -122,6 +123,7 @@ func TestLocalComposeRun(t *testing.T) { if strings.HasPrefix(containerID, "run-test_back") { //only the one-off container for back service assert.Assert(t, strings.HasPrefix(containerID, "run-test_back_run_"), containerID) + truncatedSlug = strings.Replace(containerID, "run-test_back_run_", "", 1) runContainerID = containerID 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.project": "run-test"`}) 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) { - res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "--rm", "back", "echo", "Hello again") - res.Assert(t, icmd.Expected{Out: "Hello again"}) + res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "--rm", "back", "/bin/sh", "-c", "echo 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) {