From 6ce6b63482c20c501b6962a83c520e2fccc0a02e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 28 Jul 2023 10:24:40 +0200 Subject: [PATCH] integration-cli: DockerCLIHistorySuite: replace dockerCmd Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_cli_history_test.go | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/integration-cli/docker_cli_history_test.go b/integration-cli/docker_cli_history_test.go index ef6e7439f4..400dcfb6d9 100644 --- a/integration-cli/docker_cli_history_test.go +++ b/integration-cli/docker_cli_history_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" @@ -28,7 +29,7 @@ func (s *DockerCLIHistorySuite) OnTimeout(c *testing.T) { // This is a heisen-test. Because the created timestamp of images and the behavior of // sort is not predictable it doesn't always fail. func (s *DockerCLIHistorySuite) TestBuildHistory(c *testing.T) { - name := "testbuildhistory" + const name = "testbuildhistory" buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` LABEL label.A="A" LABEL label.B="B" @@ -57,7 +58,7 @@ LABEL label.X="X" LABEL label.Y="Y" LABEL label.Z="Z"`)) - out, _ := dockerCmd(c, "history", name) + out := cli.DockerCmd(c, "history", name).Combined() actualValues := strings.Split(out, "\n")[1:27] expectedValues := [26]string{"Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"} @@ -69,7 +70,7 @@ LABEL label.Z="Z"`)) } func (s *DockerCLIHistorySuite) TestHistoryExistentImage(c *testing.T) { - dockerCmd(c, "history", "busybox") + cli.DockerCmd(c, "history", "busybox") } func (s *DockerCLIHistorySuite) TestHistoryNonExistentImage(c *testing.T) { @@ -78,26 +79,24 @@ func (s *DockerCLIHistorySuite) TestHistoryNonExistentImage(c *testing.T) { } func (s *DockerCLIHistorySuite) TestHistoryImageWithComment(c *testing.T) { - name := "testhistoryimagewithcomment" + const name = "testhistoryimagewithcomment" // make an image through docker commit [ -m messages ] + cli.DockerCmd(c, "run", "--name", name, "busybox", "true") + cli.DockerCmd(c, "wait", name) - dockerCmd(c, "run", "--name", name, "busybox", "true") - dockerCmd(c, "wait", name) - - comment := "This_is_a_comment" - dockerCmd(c, "commit", "-m="+comment, name, name) + const comment = "This_is_a_comment" + cli.DockerCmd(c, "commit", "-m="+comment, name, name) // test docker history to check comment messages - - out, _ := dockerCmd(c, "history", name) + out := cli.DockerCmd(c, "history", name).Combined() outputTabs := strings.Fields(strings.Split(out, "\n")[1]) actualValue := outputTabs[len(outputTabs)-1] assert.Assert(c, strings.Contains(actualValue, comment)) } func (s *DockerCLIHistorySuite) TestHistoryHumanOptionFalse(c *testing.T) { - out, _ := dockerCmd(c, "history", "--human=false", "busybox") + out := cli.DockerCmd(c, "history", "--human=false", "busybox").Combined() lines := strings.Split(out, "\n") sizeColumnRegex, _ := regexp.Compile("SIZE +") indices := sizeColumnRegex.FindStringIndex(lines[0]) @@ -115,7 +114,7 @@ func (s *DockerCLIHistorySuite) TestHistoryHumanOptionFalse(c *testing.T) { } func (s *DockerCLIHistorySuite) TestHistoryHumanOptionTrue(c *testing.T) { - out, _ := dockerCmd(c, "history", "--human=true", "busybox") + out := cli.DockerCmd(c, "history", "--human=true", "busybox").Combined() lines := strings.Split(out, "\n") sizeColumnRegex, _ := regexp.Compile("SIZE +") humanSizeRegexRaw := "\\d+.*B" // Matches human sizes like 10 MB, 3.2 KB, etc