mirror of
https://github.com/moby/moby.git
synced 2025-11-18 09: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:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/icmd"
|
||||
)
|
||||
|
||||
@@ -36,8 +37,8 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *testing.T) {
|
||||
if err != nil {
|
||||
c.Fatalf("Could not list plugins: %v %s", err, out)
|
||||
}
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, strings.Contains(out, "true"))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, "true"))
|
||||
}
|
||||
|
||||
// TestDaemonRestartWithPluginDisabled tests state restore for a disabled plugin
|
||||
@@ -62,8 +63,8 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *testing.T) {
|
||||
if err != nil {
|
||||
c.Fatalf("Could not list plugins: %v %s", err, out)
|
||||
}
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, strings.Contains(out, "false"))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, "false"))
|
||||
}
|
||||
|
||||
// TestDaemonKillLiveRestoreWithPlugins SIGKILLs daemon started with --live-restore.
|
||||
@@ -220,8 +221,8 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *testing.T) {
|
||||
if err != nil {
|
||||
c.Fatalf("Could not list volume: %v %s", err, out)
|
||||
}
|
||||
assert.Assert(c, strings.Contains(out, volName))
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, volName))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
|
||||
out, err = s.d.Cmd("run", "--rm", "-v", volName+":"+destDir, "busybox", "touch", destDir+destFile)
|
||||
assert.NilError(c, err, out)
|
||||
@@ -237,7 +238,7 @@ func (s *DockerDaemonSuite) TestPluginVolumeRemoveOnRestart(c *testing.T) {
|
||||
|
||||
out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pName)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
|
||||
out, err = s.d.Cmd("volume", "create", "--driver", pName, "test")
|
||||
assert.NilError(c, err, out)
|
||||
@@ -246,7 +247,7 @@ func (s *DockerDaemonSuite) TestPluginVolumeRemoveOnRestart(c *testing.T) {
|
||||
|
||||
out, err = s.d.Cmd("plugin", "disable", pName)
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, strings.Contains(out, "in use"))
|
||||
assert.Assert(c, is.Contains(out, "in use"))
|
||||
|
||||
out, err = s.d.Cmd("volume", "rm", "test")
|
||||
assert.NilError(c, err, out)
|
||||
@@ -278,12 +279,12 @@ func (s *DockerDaemonSuite) TestPluginListFilterEnabled(c *testing.T) {
|
||||
|
||||
out, err = s.d.Cmd("plugin", "ls", "--filter", "enabled=false")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, strings.Contains(out, "false"))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, "false"))
|
||||
|
||||
out, err = s.d.Cmd("plugin", "ls")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestPluginListFilterCapability(c *testing.T) {
|
||||
@@ -302,7 +303,7 @@ func (s *DockerDaemonSuite) TestPluginListFilterCapability(c *testing.T) {
|
||||
|
||||
out, err = s.d.Cmd("plugin", "ls", "--filter", "capability=volumedriver")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
|
||||
out, err = s.d.Cmd("plugin", "ls", "--filter", "capability=authz")
|
||||
assert.NilError(c, err, out)
|
||||
@@ -310,5 +311,5 @@ func (s *DockerDaemonSuite) TestPluginListFilterCapability(c *testing.T) {
|
||||
|
||||
out, err = s.d.Cmd("plugin", "ls")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.Contains(out, pName))
|
||||
assert.Assert(c, is.Contains(out, pName))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user