1
0
mirror of https://github.com/moby/moby.git synced 2025-07-29 07:21:35 +03:00

rm-gocheck: Matches -> cmp.Regexp

sed -E -i '0,/^import "github\.com/ s/^(import "github\.com.*)/\1\nimport "gotest.tools\/assert\/cmp")/' \
-- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_links_test.go" \
&& \
sed -E -i '0,/^\t+"github\.com/ s/(^\t+"github\.com.*)/\1\n"gotest.tools\/assert\/cmp"/' \
-- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_links_test.go" \
&& \
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Matches, (.*)\)$#assert.Assert(c, eg_matches(is.Regexp, \1, \2))#g' \
-- "integration-cli/docker_cli_images_test.go" "integration-cli/docker_api_containers_test.go" \
&& \
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Matches, (.*)\)$#assert.Assert(c, eg_matches(cmp.Regexp, \1, \2))#g' \
-- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_links_test.go" \
&& \
go get -d golang.org/x/tools/cmd/eg && dir=$(go env GOPATH)/src/golang.org/x/tools && git -C "$dir" fetch https://github.com/tiborvass/tools handle-variadic && git -C "$dir" checkout 61a94b82347c29b3289e83190aa3dda74d47abbb && go install golang.org/x/tools/cmd/eg \
&& \
/bin/echo -e 'package main\nvar eg_matches func(func(cmp.RegexOrPattern, string) cmp.Comparison, interface{}, string, ...interface{}) bool' > ./integration-cli/eg_helper.go \
&& \
goimports -w ./integration-cli \
&& \
eg -w -t template.matches.go -- ./integration-cli \
&& \
rm -f ./integration-cli/eg_helper.go \
&& \
go run rm-gocheck.go redress '\bassert\.Assert\b.*(\(|,)\s*$' \
 "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_links_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass
2019-09-09 21:07:08 +00:00
parent 59e55dcdd0
commit f2c9e391fc
5 changed files with 76 additions and 11 deletions

View File

@ -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) {