mirror of
https://github.com/moby/moby.git
synced 2025-11-09 13:41:11 +03:00
tests: migrate strings.Contains -> is.Contains in assertions
Migrated using
find . -type f -name "*_test.go" |
xargs gofmt -w \
-r "assert.Check(t, strings.Contains(a, b)) -> assert.Check(t, is.Contains(a, b))"
find . -type f -name "*_test.go" |
xargs gofmt -w \
-r "assert.Assert(t, strings.Contains(a, b)) -> assert.Assert(t, is.Contains(a, b))"
Using a boolean in assert.Assert or assert.Check results in error
messages that don't contain the actual problematic string, and when
running the integration suite on an actual machine (where the source
code parsing doesn't work) this makes it almost impossible to figure out
what the actual error is.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/testutil"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/icmd"
|
||||
"gotest.tools/v3/skip"
|
||||
)
|
||||
@@ -89,7 +90,7 @@ func (s *DockerCLISaveLoadSuite) TestSaveAndLoadWithProgressBar(c *testing.T) {
|
||||
cli.DockerCmd(c, "tag", "busybox", name)
|
||||
out := cli.DockerCmd(c, "load", "-i", tmptar).Combined()
|
||||
expected := fmt.Sprintf("The image %s:latest already exists, renaming the old one with ID", name)
|
||||
assert.Assert(c, strings.Contains(out, expected))
|
||||
assert.Assert(c, is.Contains(out, expected))
|
||||
}
|
||||
|
||||
// fail because load didn't receive data from stdin
|
||||
@@ -108,5 +109,5 @@ func (s *DockerCLISaveLoadSuite) TestLoadNoStdinFail(c *testing.T) {
|
||||
|
||||
n, err := p.Read(buf)
|
||||
assert.NilError(c, err) // could not read tty output
|
||||
assert.Assert(c, strings.Contains(string(buf[:n]), "requested load from stdin, but stdin is empty"))
|
||||
assert.Assert(c, is.Contains(string(buf[:n]), "requested load from stdin, but stdin is empty"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user