fix inspect format result
Currently `docker inspect -f` use json.Unmarshal() unmarshal
to interface, it will store all JSON numbers in float64, so
we use `docker inspect 4f0d73b75a0d | grep Memory` and
`docker inspect -f {{.HostConfig.Memory}} 4f0d73b75a0d` will
get different values.
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: b0ef3194aaa8c22b674ed5301c59e8e557a7e85e
Component: engine
This commit is contained in:
@ -21,3 +21,23 @@ func (s *DockerSuite) TestInspectImage(c *check.C) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectInt64(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "-m=300M", "busybox", "true")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||
}
|
||||
|
||||
out = strings.TrimSpace(out)
|
||||
|
||||
inspectCmd := exec.Command(dockerBinary, "inspect", "-f", "{{.HostConfig.Memory}}", out)
|
||||
inspectOut, _, err := runCommandWithOutput(inspectCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to inspect container: %v, output: %q", err, inspectOut)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(inspectOut) != "314572800" {
|
||||
c.Fatalf("inspect got wrong value, got: %q, expected: 314572800", inspectOut)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user