Skip to content

Commit

Permalink
modified docker_cli_kill_test.go to use c.Asserts
Browse files Browse the repository at this point in the history
Signed-off-by: Zuhayr Elahi <elahi.zuhayr@gmail.com>
  • Loading branch information
zelahi committed Oct 28, 2015
1 parent b92fd9f commit d0762a6
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions integration-cli/docker_cli_kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"strings"

"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
)

Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -70,29 +68,22 @@ 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)
c.Assert(waitRun(cid), check.IsNil)

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) {
Expand Down

0 comments on commit d0762a6

Please sign in to comment.