MCPcopy Create free account
hub / github.com/docker/compose / TestStartStopWithOneOffs

Function TestStartStopWithOneOffs

pkg/e2e/start_stop_test.go:132–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func 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
183func TestStartAlreadyRunning(t *testing.T) {
184 cli := NewParallelCLI(t, WithEnv(

Callers

nothing calls this directly

Calls 2

NewParallelCLIFunction · 0.85
RunDockerComposeCmdMethod · 0.80

Tested by

no test coverage detected