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:
Zhang Wei
2016-01-28 22:19:25 +08:00
parent 725b5b595b
commit 62a856e912
34 changed files with 298 additions and 591 deletions

View File

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