(t *testing.T)
| 31 | ) |
| 32 | |
| 33 | func 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 | |
| 76 | func TestLocalComposeLogsFollow(t *testing.T) { |
| 77 | c := NewCLI(t, WithEnv("REPEAT=20")) |
nothing calls this directly
no test coverage detected