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

Function TestRestart

pkg/e2e/restart_test.go:36–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestRestart(t *testing.T) {
37 c := NewParallelCLI(t)
38 const projectName = "e2e-restart"
39
40 t.Run("Up a project", func(t *testing.T) {
41 // This is just to ensure the containers do NOT exist
42 c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
43
44 res := c.RunDockerComposeCmd(t, "-f", "./fixtures/restart-test/compose.yaml", "--project-name", projectName, "up", "-d")
45 assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-restart-restart-1 Started"), res.Combined())
46
47 c.WaitForCmdResult(t, c.NewDockerComposeCmd(t, "--project-name", projectName, "ps", "-a", "--format",
48 "json"),
49 StdoutContains(`"State":"exited"`), 10*time.Second, 1*time.Second)
50
51 res = c.RunDockerComposeCmd(t, "--project-name", projectName, "ps", "-a")
52 assertServiceStatus(t, projectName, "restart", "Exited", res.Stdout())
53
54 c.RunDockerComposeCmd(t, "-f", "./fixtures/restart-test/compose.yaml", "--project-name", projectName, "restart")
55
56 // Give the same time but it must NOT exit
57 time.Sleep(time.Second)
58
59 res = c.RunDockerComposeCmd(t, "--project-name", projectName, "ps")
60 assertServiceStatus(t, projectName, "restart", "Up", res.Stdout())
61
62 // Clean up
63 c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
64 })
65}
66
67func TestRestartWithDependencies(t *testing.T) {
68 c := NewCLI(t, WithEnv(

Callers

nothing calls this directly

Calls 6

NewParallelCLIFunction · 0.85
StdoutContainsFunction · 0.85
assertServiceStatusFunction · 0.85
RunDockerComposeCmdMethod · 0.80
WaitForCmdResultMethod · 0.80
NewDockerComposeCmdMethod · 0.80

Tested by

no test coverage detected