moby/integration-cli/docker_cli_inspect_experimental_test.go
Zhang Wei 62a856e912 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>
2016-01-29 23:39:07 +08:00

33 lines
991 B
Go

// +build experimental
package main
import (
"github.com/docker/docker/pkg/integration/checker"
"github.com/docker/engine-api/types"
"github.com/go-check/check"
)
func (s *DockerSuite) TestInspectNamedMountPoint(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "test", "-v", "data:/data", "busybox", "cat")
vol := inspectFieldJSON(c, "test", "Mounts")
var mp []types.MountPoint
err := unmarshalJSON([]byte(vol), &mp)
c.Assert(err, checker.IsNil)
c.Assert(mp, checker.HasLen, 1, check.Commentf("Expected 1 mount point"))
m := mp[0]
c.Assert(m.Name, checker.Equals, "data", check.Commentf("Expected name data"))
c.Assert(m.Driver, checker.Equals, "local", check.Commentf("Expected driver local"))
c.Assert(m.Source, checker.Not(checker.Equals), "", check.Commentf("Expected source to not be empty"))
c.Assert(m.RW, checker.Equals, true)
c.Assert(m.Destination, checker.Equals, "/data", check.Commentf("Expected destination /data"))
}