(t *testing.T)
| 130 | } |
| 131 | |
| 132 | func TestStartStopWithOneOffs(t *testing.T) { |
| 133 | c := NewParallelCLI(t) |
| 134 | const projectName = "e2e-start-stop-with-oneoffs" |
| 135 | |
| 136 | t.Run("Up", func(t *testing.T) { |
| 137 | res := c.RunDockerComposeCmd(t, "-f", "./fixtures/dependencies/compose.yaml", "--project-name", projectName, |
| 138 | "up", "-d") |
| 139 | assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop-with-oneoffs-foo-1 Started"), res.Combined()) |
| 140 | assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop-with-oneoffs-bar-1 Started"), res.Combined()) |
| 141 | }) |
| 142 | |
| 143 | t.Run("run one-off", func(t *testing.T) { |
| 144 | c.RunDockerComposeCmd(t, "-f", "./fixtures/dependencies/compose.yaml", "--project-name", projectName, "run", "-d", "bar", "sleep", "infinity") |
| 145 | res := c.RunDockerComposeCmd(t, "--project-name", projectName, "ps", "-a") |
| 146 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-foo-1"), res.Combined()) |
| 147 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-1"), res.Combined()) |
| 148 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-run"), res.Combined()) |
| 149 | }) |
| 150 | |
| 151 | t.Run("stop (not one-off containers)", func(t *testing.T) { |
| 152 | res := c.RunDockerComposeCmd(t, "--project-name", projectName, "stop") |
| 153 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-foo-1"), res.Combined()) |
| 154 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-1"), res.Combined()) |
| 155 | assert.Assert(t, !strings.Contains(res.Combined(), "e2e_start_stop_with_oneoffs-bar-run"), res.Combined()) |
| 156 | |
| 157 | res = c.RunDockerComposeCmd(t, "--project-name", projectName, "ps", "-a", "--status", "running") |
| 158 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-run"), res.Combined()) |
| 159 | }) |
| 160 | |
| 161 | t.Run("start (not one-off containers)", func(t *testing.T) { |
| 162 | res := c.RunDockerComposeCmd(t, "--project-name", projectName, "start") |
| 163 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-foo-1"), res.Combined()) |
| 164 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-1"), res.Combined()) |
| 165 | assert.Assert(t, !strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-run"), res.Combined()) |
| 166 | }) |
| 167 | |
| 168 | t.Run("restart (not one-off containers)", func(t *testing.T) { |
| 169 | res := c.RunDockerComposeCmd(t, "--project-name", projectName, "restart") |
| 170 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-foo-1"), res.Combined()) |
| 171 | assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-1"), res.Combined()) |
| 172 | assert.Assert(t, !strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar-run"), res.Combined()) |
| 173 | }) |
| 174 | |
| 175 | t.Run("down", func(t *testing.T) { |
| 176 | c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans") |
| 177 | |
| 178 | res := c.RunDockerComposeCmd(t, "--project-name", projectName, "ps", "-a", "--status", "running") |
| 179 | assert.Assert(t, !strings.Contains(res.Combined(), "e2e-start-stop-with-oneoffs-bar"), res.Combined()) |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | func TestStartAlreadyRunning(t *testing.T) { |
| 184 | cli := NewParallelCLI(t, WithEnv( |
nothing calls this directly
no test coverage detected