MCPcopy
hub / github.com/docker/compose / TestStartStop

Function TestStartStop

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

Source from the content-addressed store, hash-verified

27)
28
29func TestStartStop(t *testing.T) {
30 c := NewParallelCLI(t)
31 const projectName = "e2e-start-stop-no-dependencies"
32
33 getProjectRegx := func(status string) string {
34 // match output with random spaces like:
35 // e2e-start-stop running(3)
36 return fmt.Sprintf("%s\\s+%s\\(%d\\)", projectName, status, 2)
37 }
38
39 t.Run("Up a project", func(t *testing.T) {
40 res := c.RunDockerComposeCmd(t, "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "up",
41 "-d")
42 assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop-no-dependencies-simple-1 Started"), res.Combined())
43
44 res = c.RunDockerComposeCmd(t, "ls", "--all")
45 assert.Assert(t, is.Regexp(getProjectRegx("running"), res.Stdout()))
46
47 res = c.RunDockerComposeCmd(t, "--project-name", projectName, "ps")
48 assertServiceStatus(t, projectName, "simple", "Up", res.Stdout())
49 assertServiceStatus(t, projectName, "another", "Up", res.Stdout())
50 })
51
52 t.Run("stop project", func(t *testing.T) {
53 c.RunDockerComposeCmd(t, "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "stop")
54
55 res := c.RunDockerComposeCmd(t, "ls")
56 assert.Assert(t, !strings.Contains(res.Combined(), "e2e-start-stop-no-dependencies"), res.Combined())
57
58 res = c.RunDockerComposeCmd(t, "ls", "--all")
59 assert.Assert(t, is.Regexp(getProjectRegx("exited"), res.Stdout()))
60
61 res = c.RunDockerComposeCmd(t, "--project-name", projectName, "ps")
62 assert.Assert(t, !strings.Contains(res.Combined(), "e2e-start-stop-no-dependencies-words-1"), res.Combined())
63
64 res = c.RunDockerComposeCmd(t, "--project-name", projectName, "ps", "--all")
65 assertServiceStatus(t, projectName, "simple", "Exited", res.Stdout())
66 assertServiceStatus(t, projectName, "another", "Exited", res.Stdout())
67 })
68
69 t.Run("start project", func(t *testing.T) {
70 c.RunDockerComposeCmd(t, "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "start")
71
72 res := c.RunDockerComposeCmd(t, "ls")
73 assert.Assert(t, is.Regexp(getProjectRegx("running"), res.Stdout()))
74 })
75
76 t.Run("down", func(t *testing.T) {
77 _ = c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
78 })
79}
80
81func TestStartStopWithDependencies(t *testing.T) {
82 c := NewParallelCLI(t)

Callers

nothing calls this directly

Calls 3

NewParallelCLIFunction · 0.85
assertServiceStatusFunction · 0.85
RunDockerComposeCmdMethod · 0.80

Tested by

no test coverage detected