From 08623dc216227d6377cb4558caedd75cacf68755 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 12 Nov 2013 12:25:35 -0800 Subject: [PATCH] Fix ImageTree test --- commands.go | 14 ++++++++------ commands_test.go | 9 ++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/commands.go b/commands.go index fac70ca5d4..179a303c64 100644 --- a/commands.go +++ b/commands.go @@ -1100,16 +1100,18 @@ func (cli *DockerCli) CmdImages(args ...string) error { } var outs []APIImages - err = json.Unmarshal(body, &outs) - if err != nil { + if err := json.Unmarshal(body, &outs); err != nil { return err } - var startImageArg = cmd.Arg(0) - var startImage APIImages + var ( + startImageArg = cmd.Arg(0) + startImage APIImages + + roots []APIImages + byParent = make(map[string][]APIImages) + ) - var roots []APIImages - var byParent = make(map[string][]APIImages) for _, image := range outs { if image.ParentId == "" { roots = append(roots, image) diff --git a/commands_test.go b/commands_test.go index 6c6a8e975b..186bce2c0a 100644 --- a/commands_test.go +++ b/commands_test.go @@ -776,13 +776,12 @@ func TestImagesTree(t *testing.T) { t.Fatal(err) } cmdOutput := string(cmdOutputBytes) - regexpStrings := []string{ fmt.Sprintf("└─%s Size: (\\d+.\\d+ MB) \\(virtual \\d+.\\d+ MB\\) Tags: %s:latest", unitTestImageIDShort, unitTestImageName), - "(?m)^ └─[0-9a-f]+", - "(?m)^ └─[0-9a-f]+", - "(?m)^ └─[0-9a-f]+", - fmt.Sprintf(" └─%s Size: \\d+ B \\(virtual \\d+.\\d+ MB\\) Tags: test:latest", utils.TruncateID(image.ID)), + "(?m) └─[0-9a-f]+.*", + "(?m) └─[0-9a-f]+.*", + "(?m) └─[0-9a-f]+.*", + fmt.Sprintf("(?m)^ └─%s Size: \\d+.\\d+ MB \\(virtual \\d+.\\d+ MB\\) Tags: test:latest", utils.TruncateID(image.ID)), } compiledRegexps := []*regexp.Regexp{}