Assert error in body of function inspectField*
1. Replace raw `docker inspect -f xxx` with `inspectField`, to make code cleaner and more consistent 2. assert the error in function `inspectField*` so we don't need to assert the return value of it every time, this will make inspect easier. Signed-off-by: Zhang Wei <zhangwei555@huawei.com> Upstream-commit: 62a856e9129c9d5cf7db9ea6322c9073d68e3ea4 Component: engine
This commit is contained in:
@ -55,7 +55,7 @@ func (s *DockerSuite) TestKillWithSignal(c *check.C) {
|
||||
|
||||
dockerCmd(c, "kill", "-s", "SIGWINCH", cid)
|
||||
|
||||
running, _ := inspectField(cid, "State.Running")
|
||||
running := inspectField(c, cid, "State.Running")
|
||||
|
||||
c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after SIGWINCH"))
|
||||
}
|
||||
@ -70,7 +70,7 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
||||
c.Assert(err, check.NotNil)
|
||||
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")
|
||||
running := inspectField(c, cid, "State.Running")
|
||||
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")
|
||||
@ -81,7 +81,7 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
||||
c.Assert(err, check.NotNil)
|
||||
c.Assert(out, checker.Contains, "Invalid signal: SIG42", check.Commentf("Kill with an invalid signal error out correctly"))
|
||||
|
||||
running, _ = inspectField(cid, "State.Running")
|
||||
running = inspectField(c, cid, "State.Running")
|
||||
c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal"))
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user