From eececb9add3748fce765c3094575d3c52d8cfdbf Mon Sep 17 00:00:00 2001 From: Joana Hrotko Date: Wed, 30 Oct 2024 12:09:34 +0000 Subject: [PATCH] Add profile e2e test case to document in compose Signed-off-by: Joana Hrotko --- pkg/e2e/fixtures/profiles/docker-compose.yaml | 15 +++++++++++++++ pkg/e2e/up_test.go | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 pkg/e2e/fixtures/profiles/docker-compose.yaml diff --git a/pkg/e2e/fixtures/profiles/docker-compose.yaml b/pkg/e2e/fixtures/profiles/docker-compose.yaml new file mode 100644 index 00000000000..134d7bbc9bf --- /dev/null +++ b/pkg/e2e/fixtures/profiles/docker-compose.yaml @@ -0,0 +1,15 @@ +services: + foo: + container_name: foo_c + profiles: [ test ] + image: alpine + depends_on: [ db ] + + bar: + container_name: bar_c + profiles: [ test ] + image: alpine + + db: + container_name: db_c + image: alpine \ No newline at end of file diff --git a/pkg/e2e/up_test.go b/pkg/e2e/up_test.go index e6e138c3bce..83ce235a1d4 100644 --- a/pkg/e2e/up_test.go +++ b/pkg/e2e/up_test.go @@ -179,3 +179,16 @@ func TestUpWithAllResources(t *testing.T) { assert.Assert(t, strings.Contains(res.Combined(), fmt.Sprintf(`Volume "%s_my_vol" Created`, projectName)), res.Combined()) assert.Assert(t, strings.Contains(res.Combined(), fmt.Sprintf(`Network %s_my_net Created`, projectName)), res.Combined()) } + +func TestUpProfile(t *testing.T) { + c := NewCLI(t) + const projectName = "compose-e2e-up-profile" + t.Cleanup(func() { + c.RunDockerComposeCmd(t, "--project-name", projectName, "--profile", "test", "down", "-v") + }) + + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/docker-compose.yaml", "--project-name", projectName, "up", "foo") + assert.Assert(t, strings.Contains(res.Combined(), `Container db_c Created`), res.Combined()) + assert.Assert(t, strings.Contains(res.Combined(), `Container foo_c Created`), res.Combined()) + assert.Assert(t, !strings.Contains(res.Combined(), `Container bar_c Created`), res.Combined()) +}