(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestKillContainer(t *testing.T) { |
| 14 | result := icmd.RunCommand("docker", "run", "-d", fixtures.AlpineImage, "top") |
| 15 | result.Assert(t, icmd.Success) |
| 16 | |
| 17 | containerID := strings.TrimSpace(result.Stdout()) |
| 18 | |
| 19 | // Kill with SIGTERM should kill the process |
| 20 | result = icmd.RunCmd(icmd.Command("docker", "kill", "-s", "SIGTERM", containerID)) |
| 21 | |
| 22 | result.Assert(t, icmd.Success) |
| 23 | poll.WaitOn(t, containerStatus(t, containerID, "exited"), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(5*time.Second)) |
| 24 | |
| 25 | // Kill on a stop container should return an error |
| 26 | result = icmd.RunCmd(icmd.Command("docker", "kill", containerID)) |
| 27 | result.Assert(t, icmd.Expected{ |
| 28 | ExitCode: 1, |
| 29 | Err: "is not running", |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | func containerStatus(t *testing.T, containerID, status string) func(poll.LogT) poll.Result { |
| 34 | t.Helper() |
nothing calls this directly
no test coverage detected
searching dependent graphs…