mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
modified docker_cli_kill_test.go to use c.Asserts
Signed-off-by: Zuhayr Elahi <elahi.zuhayr@gmail.com>
This commit is contained in:
parent
b92fd9ff04
commit
d0762a60e0
1 changed files with 12 additions and 21 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue