Merge pull request #15023 from hqhq/hq_add_status_in_inspect

Add status string to State field for inspect
This commit is contained in:
Alexander Morozov
2015-08-28 08:27:36 -07:00
4 changed files with 38 additions and 2 deletions

View File

@@ -49,6 +49,38 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
dockerCmd(c, "inspect", "busybox")
}
func (s *DockerSuite) TestInspectStatus(c *check.C) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
out = strings.TrimSpace(out)
inspectOut, err := inspectField(out, "State.Status")
c.Assert(err, check.IsNil)
if inspectOut != "running" {
c.Fatalf("inspect got wrong status, got: %q, expected: running", inspectOut)
}
dockerCmd(c, "pause", out)
inspectOut, err = inspectField(out, "State.Status")
c.Assert(err, check.IsNil)
if inspectOut != "paused" {
c.Fatalf("inspect got wrong status, got: %q, expected: paused", inspectOut)
}
dockerCmd(c, "unpause", out)
inspectOut, err = inspectField(out, "State.Status")
c.Assert(err, check.IsNil)
if inspectOut != "running" {
c.Fatalf("inspect got wrong status, got: %q, expected: running", inspectOut)
}
dockerCmd(c, "stop", out)
inspectOut, err = inspectField(out, "State.Status")
c.Assert(err, check.IsNil)
if inspectOut != "exited" {
c.Fatalf("inspect got wrong status, got: %q, expected: exited", inspectOut)
}
}
func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
//Both the container and image are named busybox. docker inspect will fetch container