1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #18932 from wenchma/same_name_of_container_image

Update integration tests when container and image have same name
This commit is contained in:
Vincent Demeester 2016-01-01 21:40:51 +01:00
commit 1a5b97c761
3 changed files with 18 additions and 10 deletions

View file

@ -20,8 +20,9 @@ parent = "smn_cli"
values are "image" or "container" values are "image" or "container"
-s, --size Display total file sizes if the type is container -s, --size Display total file sizes if the type is container
By default, this will render all results in a JSON array. If a format is By default, this will render all results in a JSON array. If the container and
specified, the given template will be executed for each result. image have the same name, this will return container JSON for unspecified type.
If a format is specified, the given template will be executed for each result.
Go's [text/template](http://golang.org/pkg/text/template/) package Go's [text/template](http://golang.org/pkg/text/template/) package
describes all the details of the format. describes all the details of the format.

View file

@ -49,8 +49,12 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
//Both the container and image are named busybox. docker inspect will fetch the container JSON. //Both the container and image are named busybox. docker inspect will fetch the container JSON.
//If the container JSON is not available, it will go for the image JSON. //If the container JSON is not available, it will go for the image JSON.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
dockerCmd(c, "inspect", "busybox") containerID := strings.TrimSpace(out)
inspectOut, err := inspectField("busybox", "Id")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(inspectOut), checker.Equals, containerID)
} }
func (s *DockerSuite) TestInspectStatus(c *check.C) { func (s *DockerSuite) TestInspectStatus(c *check.C) {
@ -329,13 +333,15 @@ func (s *DockerSuite) TestInspectSizeFlagImage(c *check.C) {
} }
func (s *DockerSuite) TestInspectTempateError(c *check.C) { func (s *DockerSuite) TestInspectTempateError(c *check.C) {
//Both the container and image are named busybox. docker inspect will fetch container // Template parsing error for both the container and image.
//JSON State.Running field. If the field is true, it's a container.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top") dockerCmd(c, "run", "--name=container1", "-d", "busybox", "top")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox") out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "container1")
c.Assert(err, check.Not(check.IsNil))
c.Assert(out, checker.Contains, "Template parsing error")
out, _, err = dockerCmdWithError("inspect", "--type=image", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox")
c.Assert(err, check.Not(check.IsNil)) c.Assert(err, check.Not(check.IsNil))
c.Assert(out, checker.Contains, "Template parsing error") c.Assert(out, checker.Contains, "Template parsing error")
} }

View file

@ -16,8 +16,9 @@ CONTAINER|IMAGE [CONTAINER|IMAGE...]
This displays all the information available in Docker for a given This displays all the information available in Docker for a given
container or image. By default, this will render all results in a JSON container or image. By default, this will render all results in a JSON
array. If a format is specified, the given template will be executed for array. If the container and image have the same name, this will return
each result. container JSON for unspecified type. If a format is specified, the given
template will be executed for each result.
# OPTIONS # OPTIONS
**--help** **--help**