From 61d6240069cda31559523b98cecb6b340a9d45fd Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 3 Dec 2015 13:55:18 -0800 Subject: [PATCH] Add test for inspect with a sha256 prefix Signed-off-by: Tonis Tiigi --- integration-cli/docker_cli_inspect_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go index 2e2c7b94ac..a4387f9707 100644 --- a/integration-cli/docker_cli_inspect_test.go +++ b/integration-cli/docker_cli_inspect_test.go @@ -342,3 +342,17 @@ func (s *DockerSuite) TestInspectJSONFields(c *check.C) { c.Assert(err, check.IsNil) c.Assert(out, checker.Equals, "[]\n") } + +func (s *DockerSuite) TestInspectByPrefix(c *check.C) { + id, err := inspectField("busybox", "Id") + c.Assert(err, checker.IsNil) + c.Assert(id, checker.HasPrefix, "sha256:") + + id2, err := inspectField(id[:10], "Id") + c.Assert(err, checker.IsNil) + c.Assert(id, checker.Equals, id2) + + id3, err := inspectField(strings.TrimPrefix(id, "sha256:")[:10], "Id") + c.Assert(err, checker.IsNil) + c.Assert(id, checker.Equals, id3) +}