1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05: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:
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

@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"strings"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
@ -19,6 +20,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
repoName := "foobar-save-load-test"
before, _ := dockerCmd(c, "commit", name, repoName)
before = strings.TrimRight(before, "\n")
tmpFile, err := ioutil.TempFile("", "foobar-save-load-test.tar")
c.Assert(err, check.IsNil)
@ -41,9 +43,10 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
out, _, err := runCommandWithOutput(loadCmd)
c.Assert(err, check.IsNil, check.Commentf(out))
after, _ := dockerCmd(c, "inspect", "-f", "{{.Id}}", repoName)
after := inspectField(c, repoName, "Id")
after = strings.TrimRight(after, "\n")
c.Assert(before, check.Equals, after) //inspect is not the same after a save / load
c.Assert(after, check.Equals, before) //inspect is not the same after a save / load
deleteImages(repoName)