(t *testing.T)
| 30 | ) |
| 31 | |
| 32 | func TestExplicitProfileUsage(t *testing.T) { |
| 33 | c := NewParallelCLI(t) |
| 34 | const projectName = "compose-e2e-explicit-profiles" |
| 35 | const profileName = "test-profile" |
| 36 | |
| 37 | t.Run("compose up with profile", func(t *testing.T) { |
| 38 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 39 | "-p", projectName, "--profile", profileName, "up", "-d") |
| 40 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 41 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps") |
| 42 | res.Assert(t, icmd.Expected{Out: regularService}) |
| 43 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 44 | }) |
| 45 | |
| 46 | t.Run("compose stop with profile", func(t *testing.T) { |
| 47 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 48 | "-p", projectName, "--profile", profileName, "stop") |
| 49 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 50 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") |
| 51 | assert.Assert(t, !strings.Contains(res.Combined(), regularService)) |
| 52 | assert.Assert(t, !strings.Contains(res.Combined(), profiledService)) |
| 53 | }) |
| 54 | |
| 55 | t.Run("compose start with profile", func(t *testing.T) { |
| 56 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 57 | "-p", projectName, "--profile", profileName, "start") |
| 58 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 59 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") |
| 60 | res.Assert(t, icmd.Expected{Out: regularService}) |
| 61 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 62 | }) |
| 63 | |
| 64 | t.Run("compose restart with profile", func(t *testing.T) { |
| 65 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 66 | "-p", projectName, "--profile", profileName, "restart") |
| 67 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 68 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") |
| 69 | res.Assert(t, icmd.Expected{Out: regularService}) |
| 70 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 71 | }) |
| 72 | |
| 73 | t.Run("down", func(t *testing.T) { |
| 74 | _ = c.RunDockerComposeCmd(t, "--project-name", projectName, "down") |
| 75 | }) |
| 76 | |
| 77 | t.Run("check containers after down", func(t *testing.T) { |
| 78 | res := c.RunDockerCmd(t, "ps") |
| 79 | assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined()) |
| 80 | }) |
| 81 | } |
| 82 | |
| 83 | func TestNoProfileUsage(t *testing.T) { |
| 84 | c := NewParallelCLI(t) |
nothing calls this directly
no test coverage detected