add e2e tests to check no profile usages

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2022-11-30 11:27:42 +01:00 committed by Nicolas De loof
parent 7fe43a8b4a
commit 6fbef29619
1 changed files with 50 additions and 0 deletions

View File

@ -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())
})
}