diff --git a/pkg/e2e/profiles_test.go b/pkg/e2e/profiles_test.go index 2eeaf6ca..799ee24c 100644 --- a/pkg/e2e/profiles_test.go +++ b/pkg/e2e/profiles_test.go @@ -57,3 +57,53 @@ func TestExplicitProfileUsage(t *testing.T) { assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined()) }) } + +func TestNoProfileUsage(t *testing.T) { + c := NewParallelCLI(t) + const projectName = "compose-e2e-no-profiles" + + t.Run("compose up without profile", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", + "-p", projectName, "up", "-d") + res.Assert(t, icmd.Expected{ExitCode: 0}) + res = c.RunDockerComposeCmd(t, "-p", projectName, "ps") + res.Assert(t, icmd.Expected{Out: "main"}) + assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service")) + }) + + t.Run("compose stop without profile", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", + "-p", projectName, "stop") + res.Assert(t, icmd.Expected{ExitCode: 0}) + res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") + assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service")) + assert.Assert(t, !strings.Contains(res.Combined(), "main")) + }) + + t.Run("compose start without profile", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", + "-p", projectName, "start") + res.Assert(t, icmd.Expected{ExitCode: 0}) + res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") + res.Assert(t, icmd.Expected{Out: "main"}) + assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service")) + }) + + t.Run("compose restart without profile", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", + "-p", projectName, "restart") + res.Assert(t, icmd.Expected{ExitCode: 0}) + res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") + res.Assert(t, icmd.Expected{Out: "main"}) + assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service")) + }) + + t.Run("down", func(t *testing.T) { + _ = c.RunDockerComposeCmd(t, "--project-name", projectName, "down") + }) + + t.Run("check containers after down", func(t *testing.T) { + res := c.RunDockerCmd(t, "ps", "--all") + assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined()) + }) +}