Merge pull request #17427 from zelahi/16756-dockercli-killtest

modified docker_cli_kill_test.go to use c.Asserts
This commit is contained in:
Vincent Demeester 2015-10-30 12:56:52 +01:00
commit 0598ff46ac

View file

@ -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) {