mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
integration-cli: remove unneeded fmt.Sprintf() in asserts
Replaced using a bit of grep-ing; ``` find . -name "*_test.go" -exec sed -E -i 's#assert.Assert\((.*), fmt.Sprintf\((.*)\)\)$#assert.Assert\(\1, \2\)#g' '{}' \; ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -3210,7 +3210,7 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) {
|
||||
assert.Assert(c, err != nil, "Expected docker run to fail!")
|
||||
|
||||
containerID, err := inspectFieldWithError(name, "Id")
|
||||
assert.Assert(c, err != nil, fmt.Sprintf("Expected not to have this container: %s!", containerID))
|
||||
assert.Assert(c, err != nil, "Expected not to have this container: %s!", containerID)
|
||||
assert.Equal(c, containerID, "", fmt.Sprintf("Expected not to have this container: %s!", containerID))
|
||||
}
|
||||
|
||||
@ -3946,7 +3946,7 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
|
||||
// We will need the following `inspect` to diagnose the issue if test fails (#21247)
|
||||
out1, err1 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "test")
|
||||
out2, err2 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "fail")
|
||||
assert.Assert(c, err != nil, fmt.Sprintf("Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2))
|
||||
assert.Assert(c, err != nil, "Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2)
|
||||
// check for windows error as well
|
||||
// TODO Windows Post TP5. Fix the error message string
|
||||
assert.Assert(c, strings.Contains(string(out), "port is already allocated") ||
|
||||
@ -4032,9 +4032,9 @@ func (s *DockerSuite) TestRunDNSInHostMode(c *testing.T) {
|
||||
expectedOutput2 := "search example.com"
|
||||
expectedOutput3 := "options timeout:3"
|
||||
out := cli.DockerCmd(c, "run", "--dns=1.2.3.4", "--dns-search=example.com", "--dns-opt=timeout:3", "--net=host", "busybox", "cat", "/etc/resolv.conf").Combined()
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput1), fmt.Sprintf("Expected '%s', but got %q", expectedOutput1, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput2), fmt.Sprintf("Expected '%s', but got %q", expectedOutput2, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput3), fmt.Sprintf("Expected '%s', but got %q", expectedOutput3, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput1), "Expected '%s', but got %q", expectedOutput1, out)
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput2), "Expected '%s', but got %q", expectedOutput2, out)
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput3), "Expected '%s', but got %q", expectedOutput3, out)
|
||||
}
|
||||
|
||||
// Test case for #21976
|
||||
@ -4043,14 +4043,14 @@ func (s *DockerSuite) TestRunAddHostInHostMode(c *testing.T) {
|
||||
|
||||
expectedOutput := "1.2.3.4\textra"
|
||||
out, _ := dockerCmd(c, "run", "--add-host=extra:1.2.3.4", "--net=host", "busybox", "cat", "/etc/hosts")
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunRmAndWait(c *testing.T) {
|
||||
dockerCmd(c, "run", "--name=test", "--rm", "-d", "busybox", "sh", "-c", "sleep 3;exit 2")
|
||||
|
||||
out, code, err := dockerCmdWithError("wait", "test")
|
||||
assert.Assert(c, err == nil, fmt.Sprintf("out: %s; exit code: %d", out, code))
|
||||
assert.Assert(c, err == nil, "out: %s; exit code: %d", out, code)
|
||||
assert.Equal(c, out, "2\n", "exit code: %d", code)
|
||||
assert.Equal(c, code, 0)
|
||||
}
|
||||
@ -4136,7 +4136,7 @@ func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) {
|
||||
|
||||
out, _, err := dockerCmdWithError("run", "--name=fail", "--log-driver=splunk", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.Contains(out, "failed to initialize logging driver"), fmt.Sprintf("error should be about logging driver, got output %s", out))
|
||||
assert.Assert(c, strings.Contains(out, "failed to initialize logging driver"), "error should be about logging driver, got output %s", out)
|
||||
// NGoroutines is not updated right away, so we need to wait before failing
|
||||
assert.Assert(c, waitForGoroutines(nroutines) == nil)
|
||||
}
|
||||
@ -4156,8 +4156,8 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) {
|
||||
}
|
||||
for _, attempt := range attempts {
|
||||
_, _, err := dockerCmdWithError("run", "--security-opt=credentialspec="+attempt.value, "busybox", "true")
|
||||
assert.Assert(c, err != nil, fmt.Sprintf("%s expected non-nil err", attempt.value))
|
||||
assert.Assert(c, strings.Contains(err.Error(), attempt.expectedError), fmt.Sprintf("%s expected %s got %s", attempt.value, attempt.expectedError, err))
|
||||
assert.Assert(c, err != nil, "%s expected non-nil err", attempt.value)
|
||||
assert.Assert(c, strings.Contains(err.Error(), attempt.expectedError), "%s expected %s got %s", attempt.value, attempt.expectedError, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -4488,11 +4488,11 @@ func (s *DockerSuite) TestRunMount(c *testing.T) {
|
||||
_, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName},
|
||||
append(opts, []string{"busybox", "top"}...)...)...)
|
||||
if testCase.valid {
|
||||
assert.Assert(c, err == nil, fmt.Sprintf("got error while creating a container with %v (%s)", opts, cName))
|
||||
assert.Assert(c, testCase.fn(cName) == nil, fmt.Sprintf("got error while executing test for %v (%s)", opts, cName))
|
||||
assert.Assert(c, err == nil, "got error while creating a container with %v (%s)", opts, cName)
|
||||
assert.Assert(c, testCase.fn(cName) == nil, "got error while executing test for %v (%s)", opts, cName)
|
||||
dockerCmd(c, "rm", "-f", cName)
|
||||
} else {
|
||||
assert.Assert(c, err != nil, fmt.Sprintf("got nil while creating a container with %v (%s)", opts, cName))
|
||||
assert.Assert(c, err != nil, "got nil while creating a container with %v (%s)", opts, cName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user