1
0
mirror of https://github.com/moby/moby.git synced 2025-11-03 16:33:18 +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:
Aleksa Sarai
2024-11-21 17:31:52 +11:00
parent 0b77888fab
commit 5e4e34a966
47 changed files with 374 additions and 349 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/creack/pty"
"github.com/docker/docker/integration-cli/cli"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
// #9860 Make sure attach ends when container ends (with no errors)
@@ -118,7 +119,7 @@ func (s *DockerCLIAttachSuite) TestAttachAfterDetach(c *testing.T) {
c.Fatal("timeout waiting for attach read")
}
assert.Assert(c, strings.Contains(string(bytes[:nBytes]), "/ #"))
assert.Assert(c, is.Contains(string(bytes[:nBytes]), "/ #"))
}
// TestAttachDetach checks that attach in tty mode can be detached using the long container ID