integration-cli/build: Parse multiline images -q output

This causes the test to have a saner error message when the `images
-q` returns multiple images separated by newline.

Before this the test would fail with `invalid reference format` when
parsing the multiline string as an image reference.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-09-04 16:20:57 +02:00
parent 4bf1a946f9
commit 5dbd198b53
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -4623,7 +4623,12 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageArg(c *testing.T) {
result.Assert(c, icmd.Success)
result = cli.DockerCmd(c, "images", "-q", "-f", "label=multifromtest=1")
parentID := strings.TrimSpace(result.Stdout())
result.Assert(c, icmd.Success)
imgs := strings.Split(strings.TrimSpace(result.Stdout()), "\n")
assert.Assert(c, cmp.Len(imgs, 1), `only one image with "multifromtest" label is expected`)
parentID := imgs[0]
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
assert.Assert(c, strings.Contains(result.Stdout(), "foo=abc"))
@ -4648,7 +4653,12 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageGlobalArg(c *testing.T) {
result.Assert(c, icmd.Success)
result = cli.DockerCmd(c, "images", "-q", "-f", "label=multifromtest=1")
parentID := strings.TrimSpace(result.Stdout())
result.Assert(c, icmd.Success)
imgs := strings.Split(strings.TrimSpace(result.Stdout()), "\n")
assert.Assert(c, cmp.Len(imgs, 1), `only one image with "multifromtest" label is expected`)
parentID := imgs[0]
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
assert.Assert(c, !strings.Contains(result.Stdout(), "tag"))