Signed-off-by: Zuhayr Elahi <elahi.zuhayr@gmail.com>
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"net/http" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/pkg/integration/checker" |
|
| 8 | 9 |
"github.com/go-check/check" |
| 9 | 10 |
) |
| 10 | 11 |
|
| ... | ... |
@@ -17,9 +18,8 @@ func (s *DockerSuite) TestKillContainer(c *check.C) {
|
| 17 | 17 |
dockerCmd(c, "kill", cleanedContainerID) |
| 18 | 18 |
|
| 19 | 19 |
out, _ = dockerCmd(c, "ps", "-q") |
| 20 |
- if strings.Contains(out, cleanedContainerID) {
|
|
| 21 |
- c.Fatal("killed container is still running")
|
|
| 22 |
- } |
|
| 20 |
+ c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
| 21 |
+ |
|
| 23 | 22 |
} |
| 24 | 23 |
|
| 25 | 24 |
func (s *DockerSuite) TestKillofStoppedContainer(c *check.C) {
|
| ... | ... |
@@ -42,9 +42,8 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
|
| 42 | 42 |
dockerCmd(c, "kill", cleanedContainerID) |
| 43 | 43 |
|
| 44 | 44 |
out, _ = dockerCmd(c, "ps", "-q") |
| 45 |
- if strings.Contains(out, cleanedContainerID) {
|
|
| 46 |
- c.Fatal("killed container is still running")
|
|
| 47 |
- } |
|
| 45 |
+ c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
| 46 |
+ |
|
| 48 | 47 |
} |
| 49 | 48 |
|
| 50 | 49 |
// regression test about correct signal parsing see #13665 |
| ... | ... |
@@ -57,9 +56,8 @@ func (s *DockerSuite) TestKillWithSignal(c *check.C) {
|
| 57 | 57 |
dockerCmd(c, "kill", "-s", "SIGWINCH", cid) |
| 58 | 58 |
|
| 59 | 59 |
running, _ := inspectField(cid, "State.Running") |
| 60 |
- if running != "true" {
|
|
| 61 |
- c.Fatal("Container should be in running state after SIGWINCH")
|
|
| 62 |
- } |
|
| 60 |
+ |
|
| 61 |
+ c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after SIGWINCH"))
|
|
| 63 | 62 |
} |
| 64 | 63 |
|
| 65 | 64 |
func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
| ... | ... |
@@ -70,14 +68,10 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
| 70 | 70 |
|
| 71 | 71 |
out, _, err := dockerCmdWithError("kill", "-s", "0", cid)
|
| 72 | 72 |
c.Assert(err, check.NotNil) |
| 73 |
- if !strings.ContainsAny(out, "Invalid signal: 0") {
|
|
| 74 |
- c.Fatal("Kill with an invalid signal didn't error out correctly")
|
|
| 75 |
- } |
|
| 73 |
+ c.Assert(out, checker.Contains, "Invalid signal: 0", check.Commentf("Kill with an invalid signal didn't error out correctly"))
|
|
| 76 | 74 |
|
| 77 | 75 |
running, _ := inspectField(cid, "State.Running") |
| 78 |
- if running != "true" {
|
|
| 79 |
- c.Fatal("Container should be in running state after an invalid signal")
|
|
| 80 |
- } |
|
| 76 |
+ c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal"))
|
|
| 81 | 77 |
|
| 82 | 78 |
out, _ = dockerCmd(c, "run", "-d", "busybox", "top") |
| 83 | 79 |
cid = strings.TrimSpace(out) |
| ... | ... |
@@ -85,14 +79,11 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
| 85 | 85 |
|
| 86 | 86 |
out, _, err = dockerCmdWithError("kill", "-s", "SIG42", cid)
|
| 87 | 87 |
c.Assert(err, check.NotNil) |
| 88 |
- if !strings.ContainsAny(out, "Invalid signal: SIG42") {
|
|
| 89 |
- c.Fatal("Kill with an invalid signal error out correctly")
|
|
| 90 |
- } |
|
| 88 |
+ c.Assert(out, checker.Contains, "Invalid signal: SIG42", check.Commentf("Kill with an invalid signal error out correctly"))
|
|
| 91 | 89 |
|
| 92 | 90 |
running, _ = inspectField(cid, "State.Running") |
| 93 |
- if running != "true" {
|
|
| 94 |
- c.Fatal("Container should be in running state after an invalid signal")
|
|
| 95 |
- } |
|
| 91 |
+ c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal"))
|
|
| 92 |
+ |
|
| 96 | 93 |
} |
| 97 | 94 |
|
| 98 | 95 |
func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {
|