From d0762a60e01339235917007fd48722ce5390ed71 Mon Sep 17 00:00:00 2001 From: Zuhayr Elahi Date: Tue, 27 Oct 2015 21:18:26 -0700 Subject: [PATCH] modified docker_cli_kill_test.go to use c.Asserts Signed-off-by: Zuhayr Elahi --- integration-cli/docker_cli_kill_test.go | 33 +++++++++---------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/integration-cli/docker_cli_kill_test.go b/integration-cli/docker_cli_kill_test.go index 5632db71e8..99093e0f54 100644 --- a/integration-cli/docker_cli_kill_test.go +++ b/integration-cli/docker_cli_kill_test.go @@ -5,6 +5,7 @@ import ( "net/http" "strings" + "github.com/docker/docker/pkg/integration/checker" "github.com/go-check/check" ) @@ -17,9 +18,8 @@ func (s *DockerSuite) TestKillContainer(c *check.C) { dockerCmd(c, "kill", cleanedContainerID) out, _ = dockerCmd(c, "ps", "-q") - if strings.Contains(out, cleanedContainerID) { - c.Fatal("killed container is still running") - } + c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running")) + } func (s *DockerSuite) TestKillofStoppedContainer(c *check.C) { @@ -42,9 +42,8 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) { dockerCmd(c, "kill", cleanedContainerID) out, _ = dockerCmd(c, "ps", "-q") - if strings.Contains(out, cleanedContainerID) { - c.Fatal("killed container is still running") - } + c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running")) + } // regression test about correct signal parsing see #13665 @@ -57,9 +56,8 @@ func (s *DockerSuite) TestKillWithSignal(c *check.C) { dockerCmd(c, "kill", "-s", "SIGWINCH", cid) running, _ := inspectField(cid, "State.Running") - if running != "true" { - c.Fatal("Container should be in running state after SIGWINCH") - } + + c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after SIGWINCH")) } func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) { @@ -70,14 +68,10 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) { out, _, err := dockerCmdWithError("kill", "-s", "0", cid) c.Assert(err, check.NotNil) - if !strings.ContainsAny(out, "Invalid signal: 0") { - c.Fatal("Kill with an invalid signal didn't error out correctly") - } + c.Assert(out, checker.Contains, "Invalid signal: 0", check.Commentf("Kill with an invalid signal didn't error out correctly")) running, _ := inspectField(cid, "State.Running") - if running != "true" { - c.Fatal("Container should be in running state after an invalid signal") - } + c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal")) out, _ = dockerCmd(c, "run", "-d", "busybox", "top") cid = strings.TrimSpace(out) @@ -85,14 +79,11 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) { out, _, err = dockerCmdWithError("kill", "-s", "SIG42", cid) c.Assert(err, check.NotNil) - if !strings.ContainsAny(out, "Invalid signal: SIG42") { - c.Fatal("Kill with an invalid signal error out correctly") - } + c.Assert(out, checker.Contains, "Invalid signal: SIG42", check.Commentf("Kill with an invalid signal error out correctly")) running, _ = inspectField(cid, "State.Running") - if running != "true" { - c.Fatal("Container should be in running state after an invalid signal") - } + c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal")) + } func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {