|
@@ -82,7 +82,7 @@ func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
|
|
|
|
|
|
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
|
|
|
|
|
|
- formatStr := fmt.Sprintf("--format='{{.State.Running}}'")
|
|
|
+ formatStr := "--format='{{.State.Running}}'"
|
|
|
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox")
|
|
|
c.Assert(out, checker.Equals, "true\n") // not a container JSON
|
|
|
}
|
|
@@ -290,19 +290,15 @@ func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *check.C) {
|
|
|
|
|
|
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
|
|
|
|
|
|
- formatStr := fmt.Sprintf("--format='{{.SizeRw}},{{.SizeRootFs}}'")
|
|
|
+ formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'"
|
|
|
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox")
|
|
|
c.Assert(strings.TrimSpace(out), check.Equals, "<nil>,<nil>", check.Commentf("Exepcted not to display size info: %s", out))
|
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestInspectSizeFlagContainer(c *check.C) {
|
|
|
-
|
|
|
- //Both the container and image are named busybox. docker inspect will fetch container
|
|
|
- //JSON SizeRw and SizeRootFs field. If there is a flag --size/-s, the fields are not <no value>.
|
|
|
-
|
|
|
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
|
|
|
|
|
|
- formatStr := fmt.Sprintf("--format='{{.SizeRw}},{{.SizeRootFs}}'")
|
|
|
+ formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'"
|
|
|
out, _ := dockerCmd(c, "inspect", "-s", "--type=container", formatStr, "busybox")
|
|
|
sz := strings.Split(out, ",")
|
|
|
|
|
@@ -311,14 +307,25 @@ func (s *DockerSuite) TestInspectSizeFlagContainer(c *check.C) {
|
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestInspectSizeFlagImage(c *check.C) {
|
|
|
+ dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
|
|
|
|
|
|
- //Both the container and image are named busybox. docker inspect will fetch image
|
|
|
- //JSON SizeRw and SizeRootFs field. There are no these fields since they are only in containers.
|
|
|
+ formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'"
|
|
|
+ out, _, err := dockerCmdWithError("inspect", "-s", "--type=image", formatStr, "busybox")
|
|
|
+
|
|
|
+ // Template error rather than <no value>
|
|
|
+ // This is a more correct behavior because images don't have sizes associated.
|
|
|
+ c.Assert(err, check.Not(check.IsNil))
|
|
|
+ c.Assert(out, checker.Contains, "Template parsing error")
|
|
|
+}
|
|
|
+
|
|
|
+func (s *DockerSuite) TestInspectTempateError(c *check.C) {
|
|
|
+ //Both the container and image are named busybox. docker inspect will fetch container
|
|
|
+ //JSON State.Running field. If the field is true, it's a container.
|
|
|
|
|
|
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
|
|
|
|
|
|
- formatStr := fmt.Sprintf("--format='{{.SizeRw}},{{.SizeRootFs}}'")
|
|
|
- out, _ := dockerCmd(c, "inspect", "-s", "--type=image", formatStr, "busybox")
|
|
|
+ out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox")
|
|
|
|
|
|
- c.Assert(strings.TrimSpace(out), check.Equals, "<no value>,<no value>", check.Commentf("Fields SizeRw and SizeRootFs are not exepcted to exist"))
|
|
|
+ c.Assert(err, check.Not(check.IsNil))
|
|
|
+ c.Assert(out, checker.Contains, "Template parsing error")
|
|
|
}
|