mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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>
This commit is contained in:
@@ -49,8 +49,7 @@ func (s *DockerSuite) TestCommitPausedContainer(c *check.C) {
|
||||
|
||||
out, _ = dockerCmd(c, "commit", cleanedContainerID)
|
||||
|
||||
out, err := inspectField(cleanedContainerID, "State.Paused")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("%s", out))
|
||||
out = inspectField(c, cleanedContainerID, "State.Paused")
|
||||
// commit should not unpause a paused container
|
||||
c.Assert(out, checker.Contains, "true")
|
||||
}
|
||||
@@ -139,8 +138,7 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
|
||||
}
|
||||
|
||||
for conf, value := range expected {
|
||||
res, err := inspectField(imageID, conf)
|
||||
c.Assert(err, checker.IsNil, check.Commentf("%s('%s')", conf, res))
|
||||
res := inspectField(c, imageID, conf)
|
||||
if res != value {
|
||||
c.Errorf("%s('%s'), expected %s", conf, res, value)
|
||||
}
|
||||
@@ -165,12 +163,10 @@ func (s *DockerSuite) TestCommitMergeConfigRun(c *check.C) {
|
||||
Cmd []string
|
||||
}
|
||||
config1 := cfg{}
|
||||
err := inspectFieldAndMarshall(id, "Config", &config1)
|
||||
c.Assert(err, checker.IsNil)
|
||||
inspectFieldAndMarshall(c, id, "Config", &config1)
|
||||
|
||||
config2 := cfg{}
|
||||
err = inspectFieldAndMarshall(name, "Config", &config2)
|
||||
c.Assert(err, checker.IsNil)
|
||||
inspectFieldAndMarshall(c, name, "Config", &config2)
|
||||
|
||||
// Env has at least PATH loaded as well here, so let's just grab the FOO one
|
||||
var env1, env2 string
|
||||
|
||||
Reference in New Issue
Block a user