diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index ec5312d2b7..984f4d86c2 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -1066,7 +1066,13 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) } b, err := request.ReadBody(body) assert.NilError(c, err) - assert.Assert(c, string(b), checker.Matches, "Path cannot be empty\n") + assert.Assert(c, is.Regexp("^"+ + + "Path cannot be empty\n"+ + "$", + + string(b))) + } func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.T) { @@ -1087,7 +1093,13 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing. } b, err := request.ReadBody(body) assert.NilError(c, err) - assert.Assert(c, string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n") + assert.Assert(c, is.Regexp("^"+ + + ("Could not find the file /notexist in container "+name+"\n")+ + "$", + + string(b))) + } func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) { diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 44b271b45b..384c9b8103 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -30,6 +30,7 @@ import ( "github.com/moby/buildkit/frontend/dockerfile/command" "github.com/opencontainers/go-digest" "gotest.tools/assert" + "gotest.tools/assert/cmp" "gotest.tools/icmd" ) @@ -4803,7 +4804,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) { cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) out := cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined() - assert.Assert(c, out, checker.Matches, "bar") + assert.Assert(c, cmp.Regexp("^"+ + + "bar"+ + "$", + + out)) // change target file should invalidate cache err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644) @@ -4813,7 +4819,13 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) { assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache") out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined() - assert.Assert(c, out, checker.Matches, "baz") + assert.Assert(c, cmp.Regexp("^"+ + + "baz"+ + "$", + + out)) + } func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) { @@ -4834,7 +4846,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) { cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) out := cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined() - assert.Assert(c, out, checker.Matches, "barbaz") + assert.Assert(c, cmp.Regexp("^"+ + + "barbaz"+ + "$", + + out)) // change target file should invalidate cache err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644) @@ -4844,7 +4861,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) { assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache") out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined() - assert.Assert(c, out, checker.Matches, "barbax") + assert.Assert(c, cmp.Regexp("^"+ + + "barbax"+ + "$", + + out)) } @@ -4867,7 +4889,13 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) { cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) out := cli.DockerCmd(c, "run", "--rm", name, "cat", "asymlink").Combined() - assert.Assert(c, out, checker.Matches, "bar") + assert.Assert(c, cmp.Regexp("^"+ + + "bar"+ + "$", + + out)) + } // #17827 diff --git a/integration-cli/docker_cli_history_test.go b/integration-cli/docker_cli_history_test.go index dd5a9cf612..3059462d99 100644 --- a/integration-cli/docker_cli_history_test.go +++ b/integration-cli/docker_cli_history_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/integration-cli/cli/build" "github.com/go-check/check" "gotest.tools/assert" + "gotest.tools/assert/cmp" ) // This is a heisen-test. Because the created timestamp of images and the behavior of @@ -116,6 +117,11 @@ func (s *DockerSuite) TestHistoryHumanOptionTrue(c *testing.T) { endIndex = len(lines[i]) } sizeString := lines[i][startIndex:endIndex] - assert.Assert(c, strings.TrimSpace(sizeString), checker.Matches, humanSizeRegexRaw, check.Commentf("The size '%s' was not in human format", sizeString)) + assert.Assert(c, cmp.Regexp("^"+ + + humanSizeRegexRaw+ + "$", + + strings.TrimSpace(sizeString)), check.Commentf("The size '%s' was not in human format", sizeString)) } } diff --git a/integration-cli/docker_cli_images_test.go b/integration-cli/docker_cli_images_test.go index c2c97c914b..008dfba9f5 100644 --- a/integration-cli/docker_cli_images_test.go +++ b/integration-cli/docker_cli_images_test.go @@ -93,8 +93,20 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) { out, _ := dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match") out = strings.TrimSpace(out) - assert.Assert(c, out, checker.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID)) - assert.Assert(c, out, checker.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID)) + assert.Assert(c, is.Regexp("^"+ + + fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID)+ + "$", + + out)) + + assert.Assert(c, is.Regexp("^"+ + + fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID)+ + "$", + + out)) + assert.Assert(c, !is.Regexp("^"+fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID)+"$", out)().Success()) out, _ = dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match=me too") diff --git a/integration-cli/docker_cli_links_test.go b/integration-cli/docker_cli_links_test.go index e29b677d69..54e457c0c2 100644 --- a/integration-cli/docker_cli_links_test.go +++ b/integration-cli/docker_cli_links_test.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/runconfig" "github.com/go-check/check" "gotest.tools/assert" + "gotest.tools/assert/cmp" ) func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) { @@ -230,7 +231,13 @@ func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) { testRequires(c, DaemonIsLinux, NotUserNamespace) out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts") // /etc/hosts should be a regular file - assert.Assert(c, out, checker.Matches, "^-.+\n") + assert.Assert(c, cmp.Regexp("^"+ + + "^-.+\n"+ + "$", + + out)) + } func (s *DockerSuite) TestLinksMultipleWithSameName(c *testing.T) {