1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03: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

@ -178,8 +178,7 @@ func (s *DockerSuite) TestCreateLabels(c *check.C) {
dockerCmd(c, "create", "--name", name, "-l", "k1=v1", "--label", "k2=v2", "busybox")
actual := make(map[string]string)
err := inspectFieldAndMarshall(name, "Config.Labels", &actual)
c.Assert(err, check.IsNil)
inspectFieldAndMarshall(c, name, "Config.Labels", &actual)
if !reflect.DeepEqual(expected, actual) {
c.Fatalf("Expected %s got %s", expected, actual)
@ -201,8 +200,7 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
dockerCmd(c, "create", "--name", name, "-l", "k2=x", "--label", "k3=v3", imageName)
actual := make(map[string]string)
err = inspectFieldAndMarshall(name, "Config.Labels", &actual)
c.Assert(err, check.IsNil)
inspectFieldAndMarshall(c, name, "Config.Labels", &actual)
if !reflect.DeepEqual(expected, actual) {
c.Fatalf("Expected %s got %s", expected, actual)
@ -411,8 +409,7 @@ func (s *DockerSuite) TestCreateStopSignal(c *check.C) {
name := "test_create_stop_signal"
dockerCmd(c, "create", "--name", name, "--stop-signal", "9", "busybox")
res, err := inspectFieldJSON(name, "Config.StopSignal")
c.Assert(err, check.IsNil)
res := inspectFieldJSON(c, name, "Config.StopSignal")
c.Assert(res, checker.Contains, "9")
}