(t *testing.T)
| 131 | } |
| 132 | |
| 133 | func TestActiveProfileViaTargetedService(t *testing.T) { |
| 134 | c := NewParallelCLI(t) |
| 135 | const projectName = "compose-e2e-via-target-service-profiles" |
| 136 | const profileName = "test-profile" |
| 137 | |
| 138 | t.Run("compose up with service name", func(t *testing.T) { |
| 139 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 140 | "-p", projectName, "up", profiledService, "-d") |
| 141 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 142 | |
| 143 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps") |
| 144 | assert.Assert(t, !strings.Contains(res.Combined(), regularService)) |
| 145 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 146 | |
| 147 | res = c.RunDockerComposeCmd(t, "-p", projectName, "--profile", profileName, "ps") |
| 148 | assert.Assert(t, !strings.Contains(res.Combined(), regularService)) |
| 149 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 150 | }) |
| 151 | |
| 152 | t.Run("compose stop with service name", func(t *testing.T) { |
| 153 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 154 | "-p", projectName, "stop", profiledService) |
| 155 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 156 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") |
| 157 | assert.Assert(t, !strings.Contains(res.Combined(), regularService)) |
| 158 | assert.Assert(t, !strings.Contains(res.Combined(), profiledService)) |
| 159 | }) |
| 160 | |
| 161 | t.Run("compose start with service name", func(t *testing.T) { |
| 162 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 163 | "-p", projectName, "start", profiledService) |
| 164 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 165 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") |
| 166 | assert.Assert(t, !strings.Contains(res.Combined(), regularService)) |
| 167 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 168 | }) |
| 169 | |
| 170 | t.Run("compose restart with service name", func(t *testing.T) { |
| 171 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml", |
| 172 | "-p", projectName, "restart") |
| 173 | res.Assert(t, icmd.Expected{ExitCode: 0}) |
| 174 | res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running") |
| 175 | assert.Assert(t, !strings.Contains(res.Combined(), regularService)) |
| 176 | res.Assert(t, icmd.Expected{Out: profiledService}) |
| 177 | }) |
| 178 | |
| 179 | t.Run("down", func(t *testing.T) { |
| 180 | _ = c.RunDockerComposeCmd(t, "--project-name", projectName, "down") |
| 181 | }) |
| 182 | |
| 183 | t.Run("check containers after down", func(t *testing.T) { |
| 184 | res := c.RunDockerCmd(t, "ps") |
| 185 | assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined()) |
| 186 | }) |
| 187 | } |
| 188 | |
| 189 | func TestDotEnvProfileUsage(t *testing.T) { |
| 190 | c := NewParallelCLI(t) |
nothing calls this directly
no test coverage detected