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

Function TestLocalComposeLogs

pkg/e2e/logs_test.go:33–74  ·  pkg/e2e/logs_test.go::TestLocalComposeLogs
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestLocalComposeLogs(t *testing.T) {
34 c := NewParallelCLI(t)
35
36 const projectName = "compose-e2e-logs"
37
38 t.Run("up", func(t *testing.T) {
39 c.RunDockerComposeCmd(t, "-f", "./fixtures/logs-test/compose.yaml", "--project-name", projectName, "up", "-d")
40 })
41
42 t.Run("logs", func(t *testing.T) {
43 res := c.RunDockerComposeCmd(t, "--project-name", projectName, "logs")
44 res.Assert(t, icmd.Expected{Out: `PING localhost`})
45 res.Assert(t, icmd.Expected{Out: `hello`})
46 })
47
48 t.Run("logs ping", func(t *testing.T) {
49 res := c.RunDockerComposeCmd(t, "--project-name", projectName, "logs", "ping")
50 res.Assert(t, icmd.Expected{Out: `PING localhost`})
51 assert.Assert(t, !strings.Contains(res.Stdout(), "hello"))
52 })
53
54 t.Run("logs hello", func(t *testing.T) {
55 res := c.RunDockerComposeCmd(t, "--project-name", projectName, "logs", "hello", "ping")
56 res.Assert(t, icmd.Expected{Out: `PING localhost`})
57 res.Assert(t, icmd.Expected{Out: `hello`})
58 })
59
60 t.Run("logs hello index", func(t *testing.T) {
61 res := c.RunDockerComposeCmd(t, "--project-name", projectName, "logs", "--index", "2", "hello")
62
63 // docker-compose logs hello
64 // logs-test-hello-2 | hello
65 // logs-test-hello-1 | hello
66 t.Log(res.Stdout())
67 assert.Assert(t, !strings.Contains(res.Stdout(), "hello-1"))
68 assert.Assert(t, strings.Contains(res.Stdout(), "hello-2"))
69 })
70
71 t.Run("down", func(t *testing.T) {
72 _ = c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
73 })
74}
75
76func TestLocalComposeLogsFollow(t *testing.T) {
77 c := NewCLI(t, WithEnv("REPEAT=20"))

Callers

nothing calls this directly

Calls 3

NewParallelCLIFunction · 0.85
RunDockerComposeCmdMethod · 0.80
LogMethod · 0.65

Tested by

no test coverage detected