rm-gocheck: IsNil

sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.IsNil\b#assert.Assert(c, \1 == nil#g' \
-- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_cp_from_container_test.go" "integration-cli/docker_cli_cp_to_container_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2019-09-09 21:05:57 +00:00
parent 491ef7b901
commit 2743e2d8bc
34 changed files with 346 additions and 346 deletions

View File

@ -220,7 +220,7 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *testing.T) {
assert.NilError(c, err)
dockerCmd(c, "rm", "-f", id)
assert.Assert(c, <-chErr, checker.IsNil)
assert.Assert(c, <-chErr == nil)
}
// ChannelBuffer holds a chan of byte array that can be populate in a goroutine.
@ -656,7 +656,7 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) {
create := func(ct string) (*http.Response, io.ReadCloser, error) {
jsonData := bytes.NewBuffer(nil)
assert.Assert(c, json.NewEncoder(jsonData).Encode(config), checker.IsNil)
assert.Assert(c, json.NewEncoder(jsonData).Encode(config) == nil)
return request.Post("/containers/create", request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType(ct))
}
@ -840,7 +840,7 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *testing.T) {
ID string
}
var container createResp
assert.Assert(c, json.Unmarshal(b, &container), checker.IsNil)
assert.Assert(c, json.Unmarshal(b, &container) == nil)
out := inspectField(c, container.ID, "HostConfig.CpusetCpus")
assert.Equal(c, out, "")
@ -864,7 +864,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
assert.NilError(c, err)
b, err2 := request.ReadBody(body)
assert.Assert(c, err2, checker.IsNil)
assert.Assert(c, err2 == nil)
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
@ -917,7 +917,7 @@ func (s *DockerSuite) TestContainerAPIRestart(c *testing.T) {
err = cli.ContainerRestart(context.Background(), name, &timeout)
assert.NilError(c, err)
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil)
}
func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
@ -933,7 +933,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
err = cli.ContainerRestart(context.Background(), name, nil)
assert.NilError(c, err)
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil)
}
func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
@ -973,7 +973,7 @@ func (s *DockerSuite) TestContainerAPIStop(c *testing.T) {
err = cli.ContainerStop(context.Background(), name, &timeout)
assert.NilError(c, err)
assert.Assert(c, waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
assert.Assert(c, waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second) == nil)
// second call to start should give 304
// maybe add ContainerStartWithRaw to test it
@ -1153,7 +1153,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
out, _ = dockerCmd(c, "run", "--link", "tlink1:tlink1", "--name", "tlink2", "-d", "busybox", "top")
id2 := strings.TrimSpace(out)
assert.Assert(c, waitRun(id2), checker.IsNil)
assert.Assert(c, waitRun(id2) == nil)
links := inspectFieldJSON(c, id2, "HostConfig.Links")
assert.Equal(c, links, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers"))
@ -1238,7 +1238,7 @@ func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *testing.T) {
req.ContentLength = -1
return nil
}))
assert.Assert(c, err, checker.IsNil, check.Commentf("error creating container with chunked encoding"))
assert.Assert(c, err == nil, check.Commentf("error creating container with chunked encoding"))
defer resp.Body.Close()
assert.Equal(c, resp.StatusCode, http.StatusCreated)
}
@ -1247,7 +1247,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
out := runSleepingContainer(c)
containerID := strings.TrimSpace(out)
assert.Assert(c, waitRun(containerID), checker.IsNil)
assert.Assert(c, waitRun(containerID) == nil)
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
@ -1255,7 +1255,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
err = cli.ContainerStop(context.Background(), containerID, nil)
assert.NilError(c, err)
assert.Assert(c, waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
assert.Assert(c, waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second) == nil)
}
// #14170
@ -1544,7 +1544,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
if versions.LessThan(testEnv.DaemonAPIVersion(), "1.31") {
assert.Equal(c, *containerJSON.HostConfig.MemorySwappiness, int64(-1))
} else {
assert.Assert(c, containerJSON.HostConfig.MemorySwappiness, checker.IsNil)
assert.Assert(c, containerJSON.HostConfig.MemorySwappiness == nil)
}
}
@ -1614,7 +1614,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
assert.NilError(c, err)
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
type b struct {
stats types.ContainerStats
@ -1636,7 +1636,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
case <-time.After(2 * time.Second):
c.Fatal("stream was not closed after container was removed")
case sr := <-bc:
assert.Assert(c, sr.err, checker.IsNil)
assert.Assert(c, sr.err == nil)
sr.stats.Body.Close()
}
}
@ -2052,7 +2052,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
assert.NilError(c, err)
defer os.RemoveAll(tmpDir3)
assert.Assert(c, mount.Mount(tmpDir3, tmpDir3, "none", "bind,shared"), checker.IsNil)
assert.Assert(c, mount.Mount(tmpDir3, tmpDir3, "none", "bind,shared") == nil)
cases = append(cases, []testCase{
{

View File

@ -147,7 +147,7 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
stdout, err := cmd.StdoutPipe()
assert.NilError(c, err)
defer stdout.Close()
assert.Assert(c, cmd.Start(), checker.IsNil)
assert.Assert(c, cmd.Start() == nil)
defer func() {
cmd.Process.Kill()
cmd.Wait()
@ -159,7 +159,7 @@ func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), "hello")
assert.Assert(c, stdin.Close(), checker.IsNil)
assert.Assert(c, stdin.Close() == nil)
// Expect container to still be running after stdin is closed
running := inspectField(c, id, "State.Running")

View File

@ -51,7 +51,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) {
case err := <-errChan:
tty.Close()
out, _ := ioutil.ReadAll(pty)
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", string(out)))
assert.Assert(c, err == nil, check.Commentf("out: %v", string(out)))
case <-time.After(attachWait):
c.Fatal("timed out without attach returning")
}
@ -74,7 +74,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) {
close(cmdExit)
}()
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
cpty.Write([]byte{16})
time.Sleep(100 * time.Millisecond)

View File

@ -5513,8 +5513,8 @@ func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
var layers1 []string
var layers2 []string
assert.Assert(c, json.Unmarshal([]byte(layers1Str), &layers1), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(layers2Str), &layers2), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(layers1Str), &layers1) == nil)
assert.Assert(c, json.Unmarshal([]byte(layers2Str), &layers2) == nil)
assert.Equal(c, len(layers1), len(layers2))
for i := 0; i < len(layers1)-1; i++ {

View File

@ -56,7 +56,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
var c1 hostConfig
err := json.Unmarshal([]byte(cfg), &c1)
assert.Assert(c, err, checker.IsNil, check.Commentf(cfg))
assert.Assert(c, err == nil, check.Commentf(cfg))
assert.Equal(c, c1.Memory, int64(64*1024*1024), check.Commentf("resource constraints not set properly for Memory"))
assert.Equal(c, c1.MemorySwap, int64(-1), check.Commentf("resource constraints not set properly for MemorySwap"))
@ -74,7 +74,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
var c2 hostConfig
err = json.Unmarshal([]byte(cfg), &c2)
assert.Assert(c, err, checker.IsNil, check.Commentf(cfg))
assert.Assert(c, err == nil, check.Commentf(cfg))
assert.Assert(c, c2.Memory != int64(64*1024*1024), check.Commentf("resource leaked from build for Memory"))
assert.Assert(c, c2.MemorySwap != int64(-1), check.Commentf("resource leaked from build for MemorySwap"))
@ -82,7 +82,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
assert.Assert(c, c2.CpusetMems != "0", check.Commentf("resource leaked from build for CpusetMems"))
assert.Assert(c, c2.CPUShares != int64(100), check.Commentf("resource leaked from build for CPUShares"))
assert.Assert(c, c2.CPUQuota != int64(8000), check.Commentf("resource leaked from build for CPUQuota"))
assert.Assert(c, c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits"))
assert.Assert(c, c2.Ulimits == nil, check.Commentf("resource leaked from build for Ulimits"))
}
func (s *DockerSuite) TestBuildAddChangeOwnership(c *testing.T) {

View File

@ -389,7 +389,7 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) {
digest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil, check.Commentf("error setting up image"))
assert.Assert(c, err == nil, check.Commentf("error setting up image"))
imageReference := fmt.Sprintf("%s@%s", repoName, digest)
@ -568,14 +568,14 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil, check.Commentf("error setting up image"))
assert.Assert(c, err == nil, check.Commentf("error setting up image"))
// Load the target manifest blob.
manifestBlob := s.reg.ReadBlobContents(c, manifestDigest)
var imgManifest schema1.Manifest
err = json.Unmarshal(manifestBlob, &imgManifest)
assert.Assert(c, err, checker.IsNil, check.Commentf("unable to decode image manifest from blob"))
assert.Assert(c, err == nil, check.Commentf("unable to decode image manifest from blob"))
// Change a layer in the manifest.
imgManifest.FSLayers[0] = schema1.FSLayer{
@ -588,7 +588,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing
defer undo()
alteredManifestBlob, err := json.MarshalIndent(imgManifest, "", " ")
assert.Assert(c, err, checker.IsNil, check.Commentf("unable to encode altered image manifest to JSON"))
assert.Assert(c, err == nil, check.Commentf("unable to encode altered image manifest to JSON"))
s.reg.WriteBlobContents(c, manifestDigest, alteredManifestBlob)
@ -610,14 +610,14 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing
func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
// Load the target manifest blob.
manifestBlob := s.reg.ReadBlobContents(c, manifestDigest)
var imgManifest schema2.Manifest
err = json.Unmarshal(manifestBlob, &imgManifest)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
// Next, get the digest of one of the layers from the manifest.
targetLayerDigest := imgManifest.Layers[0].Digest
@ -653,14 +653,14 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
// Load the target manifest blob.
manifestBlob := s.reg.ReadBlobContents(c, manifestDigest)
var imgManifest schema1.Manifest
err = json.Unmarshal(manifestBlob, &imgManifest)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
// Next, get the digest of one of the layers from the manifest.
targetLayerDigest := imgManifest.FSLayers[0].BlobSum

View File

@ -36,38 +36,38 @@ func (s *DockerSuite) TestCpFromSymlinkDestination(c *testing.T) {
srcPath := containerCpPath(containerID, "/file2")
dstPath := cpPath(tmpDir, "symlinkToFile1")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, dstPath, "file1"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, dstPath, "file1") == nil)
// The file should have the contents of "file2" now.
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "file1"), "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "file1"), "file2\n") == nil)
// Next, copy a file from the container to a symlink to a directory. This
// should copy the file into the symlink target directory.
dstPath = cpPath(tmpDir, "symlinkToDir1")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, dstPath, "dir1"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, dstPath, "dir1") == nil)
// The file should have the contents of "file2" now.
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "file2"), "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "file2"), "file2\n") == nil)
// Next, copy a file from the container to a symlink to a file that does
// not exist (a broken symlink). This should create the target file with
// the contents of the source file.
dstPath = cpPath(tmpDir, "brokenSymlinkToFileX")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, dstPath, "fileX"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, dstPath, "fileX") == nil)
// The file should have the contents of "file2" now.
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "fileX"), "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "fileX"), "file2\n") == nil)
// Next, copy a directory from the container to a symlink to a local
// directory. This should copy the directory into the symlink target
@ -75,13 +75,13 @@ func (s *DockerSuite) TestCpFromSymlinkDestination(c *testing.T) {
srcPath = containerCpPath(containerID, "/dir2")
dstPath = cpPath(tmpDir, "symlinkToDir1")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, dstPath, "dir1"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, dstPath, "dir1") == nil)
// The directory should now contain a copy of "dir2".
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "dir1/dir2/file2-1"), "file2-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "dir1/dir2/file2-1"), "file2-1\n") == nil)
// Next, copy a directory from the container to a symlink to a local
// directory that does not exist (a broken symlink). This should create
@ -89,13 +89,13 @@ func (s *DockerSuite) TestCpFromSymlinkDestination(c *testing.T) {
// should not modify the symlink.
dstPath = cpPath(tmpDir, "brokenSymlinkToDirX")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, dstPath, "dirX"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, dstPath, "dirX") == nil)
// The "dirX" directory should now be a copy of "dir2".
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "dirX/file2-1"), "file2-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "dirX/file2-1"), "file2-1\n") == nil)
}
// Possibilities are reduced to the remaining 10 cases:
@ -129,9 +129,9 @@ func (s *DockerSuite) TestCpFromCaseA(c *testing.T) {
srcPath := containerCpPath(containerID, "/root/file1")
dstPath := cpPath(tmpDir, "itWorks.txt")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
}
// B. SRC specifies a file and DST (with trailing path separator) doesn't
@ -170,11 +170,11 @@ func (s *DockerSuite) TestCpFromCaseC(c *testing.T) {
dstPath := cpPath(tmpDir, "file2")
// Ensure the local file starts with different content.
assert.Assert(c, fileContentEquals(c, dstPath, "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file2\n") == nil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
}
// D. SRC specifies a file and DST exists as a directory. This should place
@ -197,23 +197,23 @@ func (s *DockerSuite) TestCpFromCaseD(c *testing.T) {
_, err := os.Stat(dstPath)
assert.Assert(c, os.IsNotExist(err), checker.True, check.Commentf("did not expect dstPath %q to exist", dstPath))
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
assert.Assert(c, os.RemoveAll(dstDir), checker.IsNil)
assert.Assert(c, os.RemoveAll(dstDir) == nil)
// unable to make dstDir
assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)), checker.IsNil)
assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)) == nil)
dstDir = cpPathTrailingSep(tmpDir, "dir1")
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
}
// E. SRC specifies a directory and DST does not exist. This should create a
@ -231,20 +231,20 @@ func (s *DockerSuite) TestCpFromCaseE(c *testing.T) {
dstDir := cpPath(tmpDir, "testDir")
dstPath := filepath.Join(dstDir, "file1-1")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
assert.Assert(c, os.RemoveAll(dstDir), checker.IsNil)
assert.Assert(c, os.RemoveAll(dstDir) == nil)
dstDir = cpPathTrailingSep(tmpDir, "testDir")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
// F. SRC specifies a directory and DST exists as a file. This should cause an
@ -288,23 +288,23 @@ func (s *DockerSuite) TestCpFromCaseG(c *testing.T) {
resultDir := filepath.Join(dstDir, "dir1")
dstPath := filepath.Join(resultDir, "file1-1")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
assert.Assert(c, os.RemoveAll(dstDir), checker.IsNil)
assert.Assert(c, os.RemoveAll(dstDir) == nil)
// unable to make dstDir
assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)), checker.IsNil)
assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)) == nil)
dstDir = cpPathTrailingSep(tmpDir, "dir2")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
// H. SRC specifies a directory's contents only and DST does not exist. This
@ -322,20 +322,20 @@ func (s *DockerSuite) TestCpFromCaseH(c *testing.T) {
dstDir := cpPath(tmpDir, "testDir")
dstPath := filepath.Join(dstDir, "file1-1")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove resultDir
assert.Assert(c, os.RemoveAll(dstDir), checker.IsNil)
assert.Assert(c, os.RemoveAll(dstDir) == nil)
dstDir = cpPathTrailingSep(tmpDir, "testDir")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
// I. SRC specifies a directory's contents only and DST exists as a file. This
@ -380,21 +380,21 @@ func (s *DockerSuite) TestCpFromCaseJ(c *testing.T) {
dstDir := cpPath(tmpDir, "dir2")
dstPath := filepath.Join(dstDir, "file1-1")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
assert.Assert(c, os.RemoveAll(dstDir), checker.IsNil)
assert.Assert(c, os.RemoveAll(dstDir) == nil)
// unable to make dstDir
assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)), checker.IsNil)
assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)) == nil)
dstDir = cpPathTrailingSep(tmpDir, "dir2")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}

View File

@ -40,38 +40,38 @@ func (s *DockerSuite) TestCpToSymlinkDestination(c *testing.T) {
srcPath := cpPath(testVol, "file2")
dstPath := containerCpPath(containerID, "/vol2/symlinkToFile1")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToFile1"), "file1"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToFile1"), "file1") == nil)
// The file should have the contents of "file2" now.
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "file1"), "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "file1"), "file2\n") == nil)
// Next, copy a local file to a symlink to a directory in the container.
// This should copy the file into the symlink target directory.
dstPath = containerCpPath(containerID, "/vol2/symlinkToDir1")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1") == nil)
// The file should have the contents of "file2" now.
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "file2"), "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "file2"), "file2\n") == nil)
// Next, copy a file to a symlink to a file that does not exist (a broken
// symlink) in the container. This should create the target file with the
// contents of the source file.
dstPath = containerCpPath(containerID, "/vol2/brokenSymlinkToFileX")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToFileX"), "fileX"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToFileX"), "fileX") == nil)
// The file should have the contents of "file2" now.
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "fileX"), "file2\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "fileX"), "file2\n") == nil)
// Next, copy a local directory to a symlink to a directory in the
// container. This should copy the directory into the symlink target
@ -79,13 +79,13 @@ func (s *DockerSuite) TestCpToSymlinkDestination(c *testing.T) {
srcPath = cpPath(testVol, "/dir2")
dstPath = containerCpPath(containerID, "/vol2/symlinkToDir1")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1") == nil)
// The directory should now contain a copy of "dir2".
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "dir1/dir2/file2-1"), "file2-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "dir1/dir2/file2-1"), "file2-1\n") == nil)
// Next, copy a local directory to a symlink to a local directory that does
// not exist (a broken symlink) in the container. This should create the
@ -93,13 +93,13 @@ func (s *DockerSuite) TestCpToSymlinkDestination(c *testing.T) {
// should not modify the symlink.
dstPath = containerCpPath(containerID, "/vol2/brokenSymlinkToDirX")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToDirX"), "dirX"), checker.IsNil)
assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToDirX"), "dirX") == nil)
// The "dirX" directory should now be a copy of "dir2".
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "dirX/file2-1"), "file2-1\n"), checker.IsNil)
assert.Assert(c, fileContentEquals(c, cpPath(testVol, "dirX/file2-1"), "file2-1\n") == nil)
}
// Possibilities are reduced to the remaining 10 cases:
@ -134,9 +134,9 @@ func (s *DockerSuite) TestCpToCaseA(c *testing.T) {
srcPath := cpPath(tmpDir, "file1")
dstPath := containerCpPath(containerID, "/root/itWorks.txt")
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
}
// B. SRC specifies a file and DST (with trailing path separator) doesn't
@ -179,12 +179,12 @@ func (s *DockerSuite) TestCpToCaseC(c *testing.T) {
dstPath := containerCpPath(containerID, "/root/file2")
// Ensure the container's file starts with the original content.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file2\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file2\n") == nil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// Should now contain file1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
}
// D. SRC specifies a file and DST exists as a directory. This should place
@ -206,12 +206,12 @@ func (s *DockerSuite) TestCpToCaseD(c *testing.T) {
dstDir := containerCpPath(containerID, "dir1")
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
// Should now contain file1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@ -224,12 +224,12 @@ func (s *DockerSuite) TestCpToCaseD(c *testing.T) {
dstDir = containerCpPathTrailingSep(containerID, "dir1")
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
// Should now contain file1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
}
// E. SRC specifies a directory and DST does not exist. This should create a
@ -249,10 +249,10 @@ func (s *DockerSuite) TestCpToCaseE(c *testing.T) {
srcDir := cpPath(tmpDir, "dir1")
dstDir := containerCpPath(containerID, "testDir")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@ -263,10 +263,10 @@ func (s *DockerSuite) TestCpToCaseE(c *testing.T) {
dstDir = containerCpPathTrailingSep(containerID, "testDir")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// F. SRC specifies a directory and DST exists as a file. This should cause an
@ -310,12 +310,12 @@ func (s *DockerSuite) TestCpToCaseG(c *testing.T) {
dstDir := containerCpPath(containerID, "/root/dir2")
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@ -328,12 +328,12 @@ func (s *DockerSuite) TestCpToCaseG(c *testing.T) {
dstDir = containerCpPathTrailingSep(containerID, "/dir2")
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// H. SRC specifies a directory's contents only and DST does not exist. This
@ -353,10 +353,10 @@ func (s *DockerSuite) TestCpToCaseH(c *testing.T) {
srcDir := cpPathTrailingSep(tmpDir, "dir1") + "."
dstDir := containerCpPath(containerID, "testDir")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@ -367,10 +367,10 @@ func (s *DockerSuite) TestCpToCaseH(c *testing.T) {
dstDir = containerCpPathTrailingSep(containerID, "testDir")
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// I. SRC specifies a directory's contents only and DST exists as a file. This
@ -416,12 +416,12 @@ func (s *DockerSuite) TestCpToCaseJ(c *testing.T) {
dstDir := containerCpPath(containerID, "/dir2")
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@ -433,12 +433,12 @@ func (s *DockerSuite) TestCpToCaseJ(c *testing.T) {
dstDir = containerCpPathTrailingSep(containerID, "/dir2")
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// The `docker cp` command should also ensure that you cannot
@ -465,7 +465,7 @@ func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *testing.T) {
assert.Assert(c, isCpCannotCopyReadOnly(err), checker.True, check.Commentf("expected ErrContainerRootfsReadonly error, but got %T: %s", err, err))
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
}
// The `docker cp` command should also ensure that you
@ -492,5 +492,5 @@ func (s *DockerSuite) TestCpToErrReadOnlyVolume(c *testing.T) {
assert.Assert(c, isCpCannotCopyReadOnly(err), checker.True, check.Commentf("expected ErrVolumeReadonly error, but got %T: %s", err, err))
// Ensure that dstPath doesn't exist.
assert.Assert(c, containerStartOutputEquals(c, containerID, ""), checker.IsNil)
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
}

View File

@ -37,7 +37,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) {
}
err := json.Unmarshal([]byte(out), &containers)
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
assert.Assert(c, err == nil, check.Commentf("Error inspecting the container: %s", err))
assert.Equal(c, len(containers), 1)
cont := containers[0]
@ -96,7 +96,7 @@ func (s *DockerSuite) TestCreateHostConfig(c *testing.T) {
}
err := json.Unmarshal([]byte(out), &containers)
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
assert.Assert(c, err == nil, check.Commentf("Error inspecting the container: %s", err))
assert.Equal(c, len(containers), 1)
cont := containers[0]
@ -117,7 +117,7 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) {
}
}
err := json.Unmarshal([]byte(out), &containers)
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
assert.Assert(c, err == nil, check.Commentf("Error inspecting the container: %s", err))
assert.Equal(c, len(containers), 1)
cont := containers[0]
@ -147,7 +147,7 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) {
}
err := json.Unmarshal([]byte(out), &containers)
assert.Assert(c, err, checker.IsNil, check.Commentf("Error inspecting the container: %s", err))
assert.Assert(c, err == nil, check.Commentf("Error inspecting the container: %s", err))
assert.Equal(c, len(containers), 1)
cont := containers[0]
@ -179,7 +179,7 @@ func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) {
dockerCmd(c, "create", "--name", name, "-v", prefix+slash+"foo", "busybox")
dir, err := inspectMountSourceField(name, prefix+slash+"foo")
assert.Assert(c, err, checker.IsNil, check.Commentf("Error getting volume host path: %q", err))
assert.Assert(c, err == nil, check.Commentf("Error getting volume host path: %q", err))
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
c.Fatalf("Volume was not created")

View File

@ -130,7 +130,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *testing.T) {
var format string
for name, shouldRun := range m {
out, err := s.d.Cmd("ps")
assert.Assert(c, err, checker.IsNil, check.Commentf("run ps: %v", out))
assert.Assert(c, err == nil, check.Commentf("run ps: %v", out))
if shouldRun {
format = "%scontainer %q is not running"
} else {
@ -240,11 +240,11 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T)
}
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
assert.Assert(c, err, checker.IsNil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err))
assert.Assert(c, err == nil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err))
basesizeAfterRestart := getBaseDeviceSize(c, s.d)
newBasesize, err := convertBasesize(newBasesizeBytes)
assert.Assert(c, err, checker.IsNil, check.Commentf("Error in converting base device size: %v", err))
assert.Assert(c, err == nil, check.Commentf("Error in converting base device size: %v", err))
assert.Equal(c, newBasesize, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set"))
s.d.Stop(c)
}
@ -1151,7 +1151,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *te
build.WithoutCache,
)
comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
assert.Assert(c, result.Error, checker.IsNil, comment)
assert.Assert(c, result.Error == nil, comment)
assert.Equal(c, result.ExitCode, 0, comment)
assert.Assert(c, result.Combined(), checker.Contains, "foo", comment)
}
@ -1223,7 +1223,7 @@ func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *testing.T) {
}
content, err := s.d.ReadLogFile()
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
if !strings.Contains(string(content), "Public Key ID does not match") {
c.Fatalf("Missing KeyID message from daemon logs: %s", string(content))
@ -1749,7 +1749,7 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T
break
}
ip, err := s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.IPAddress}}'", contName)
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", ip))
assert.Assert(c, err == nil, check.Commentf("%s", ip))
assert.Assert(c, ip != bridgeIP)
cont++
@ -1763,7 +1763,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) {
testDir, err := ioutil.TempDir("", "no-space-left-on-device-test")
assert.NilError(c, err)
defer os.RemoveAll(testDir)
assert.Assert(c, mount.MakeRShared(testDir), checker.IsNil)
assert.Assert(c, mount.MakeRShared(testDir) == nil)
defer mount.Unmount(testDir)
// create a 3MiB image (with a 2MiB ext4 fs) and mount it as graph root
@ -1999,14 +1999,14 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) {
id := strings.TrimSpace(out)
// kill the daemon
assert.Assert(c, s.d.Kill(), checker.IsNil)
assert.Assert(c, s.d.Kill() == nil)
// Check if there are mounts with container id visible from the host.
// If not, those mounts exist in container's own mount ns, and so
// the following check for mounts being cleared is pointless.
skipMountCheck := false
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", mountOut))
assert.Assert(c, err == nil, check.Commentf("Output: %s", mountOut))
if !strings.Contains(string(mountOut), id) {
skipMountCheck = true
}
@ -2031,7 +2031,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) {
}
// Now, container mounts should be gone.
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", mountOut))
assert.Assert(c, err == nil, check.Commentf("Output: %s", mountOut))
comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
assert.Equal(c, strings.Contains(string(mountOut), id), false, comment)
}
@ -2196,7 +2196,7 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T)
// daemon config file
daemonConfig := `{ "debug" : false }`
configFile, err := ioutil.TempFile("", "test-daemon-discovery-backend-config-reload-config")
assert.Assert(c, err, checker.IsNil, check.Commentf("could not create temp file for config reload"))
assert.Assert(c, err == nil, check.Commentf("could not create temp file for config reload"))
configFilePath := configFile.Name()
defer func() {
configFile.Close()
@ -2226,7 +2226,7 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T)
assert.NilError(c, err)
err = s.d.ReloadConfig()
assert.Assert(c, err, checker.IsNil, check.Commentf("error reloading daemon config"))
assert.Assert(c, err == nil, check.Commentf("error reloading daemon config"))
out, err := s.d.Cmd("info")
assert.NilError(c, err)
@ -2288,7 +2288,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T)
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP)
time.Sleep(3 * time.Second)
@ -2329,7 +2329,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP)
time.Sleep(3 * time.Second)
@ -2347,7 +2347,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
time.Sleep(3 * time.Second)
@ -2369,7 +2369,7 @@ func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *testing.T)
build.WithoutCache,
)
comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
assert.Assert(c, result.Error, checker.IsNil, comment)
assert.Assert(c, result.Error == nil, comment)
assert.Equal(c, result.ExitCode, 0, comment)
}
@ -2438,7 +2438,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
}
`
ioutil.WriteFile(configName, []byte(config), 0644)
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// Give daemon time to reload config
<-time.After(1 * time.Second)
@ -2467,7 +2467,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
}
`
ioutil.WriteFile(configName, []byte(config), 0644)
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// Give daemon time to reload config
<-time.After(1 * time.Second)
@ -2493,7 +2493,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
}
`
ioutil.WriteFile(configName, []byte(config), 0644)
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// Give daemon time to reload config
<-time.After(1 * time.Second)
@ -2570,10 +2570,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *testing.
// top1 will exist after daemon restarts
out, err := s.d.Cmd("run", "-d", "--name", "top1", "busybox:latest", "top")
assert.Assert(c, err, checker.IsNil, check.Commentf("run top1: %v", out))
assert.Assert(c, err == nil, check.Commentf("run top1: %v", out))
// top2 will be removed after daemon restarts
out, err = s.d.Cmd("run", "-d", "--rm", "--name", "top2", "busybox:latest", "top")
assert.Assert(c, err, checker.IsNil, check.Commentf("run top2: %v", out))
assert.Assert(c, err == nil, check.Commentf("run top2: %v", out))
out, err = s.d.Cmd("ps")
assert.NilError(c, err)
@ -2668,7 +2668,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *testing.T) {
_, err := s.d.Cmd("run", "-d", "busybox", "top")
assert.NilError(c, err)
assert.Assert(c, s.d.Signal(unix.SIGINT), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGINT) == nil)
select {
case <-s.d.Wait:
@ -2702,7 +2702,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *testing.T
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
assert.Assert(c, s.d.Signal(unix.SIGHUP), checker.IsNil)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
select {
case <-s.d.Wait:
@ -2727,17 +2727,17 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
// Wait for shell command to be completed
_, err = s.d.Cmd("exec", "top", "sh", "-c", `for i in $(seq 1 5); do if [ -e /adduser_end ]; then rm -f /adduser_end && break; else sleep 1 && false; fi; done`)
assert.Assert(c, err, checker.IsNil, check.Commentf("Timeout waiting for shell command to be completed"))
assert.Assert(c, err == nil, check.Commentf("Timeout waiting for shell command to be completed"))
out1, err := s.d.Cmd("exec", "-u", "test", "top", "id")
// uid=100(test) gid=101(test) groups=101(test)
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out1))
assert.Assert(c, err == nil, check.Commentf("Output: %s", out1))
// restart daemon.
s.d.Restart(c, "--live-restore")
out2, err := s.d.Cmd("exec", "-u", "test", "top", "id")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out2))
assert.Assert(c, err == nil, check.Commentf("Output: %s", out2))
assert.Equal(c, out2, out1, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2))
out, err = s.d.Cmd("stop", "top")
@ -2790,7 +2790,7 @@ func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *testing.T) {
StartedAt time.Time
}
out, err = s.d.Cmd("inspect", "-f", "{{json .State}}", id)
assert.Assert(c, err, checker.IsNil, check.Commentf("output: %s", out))
assert.Assert(c, err == nil, check.Commentf("output: %s", out))
var origState state
err = json.Unmarshal([]byte(strings.TrimSpace(out)), &origState)
@ -2816,7 +2816,7 @@ func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *testing.T) {
}
out, err := s.d.Cmd("inspect", "-f", "{{json .State}}", id)
assert.Assert(c, err, checker.IsNil, check.Commentf("output: %s", out))
assert.Assert(c, err == nil, check.Commentf("output: %s", out))
var newState state
err = json.Unmarshal([]byte(strings.TrimSpace(out)), &newState)
@ -2855,13 +2855,13 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
testRequires(c, DaemonIsLinux)
configPath, err := ioutil.TempDir("", "test-daemon-shm-size-reload-config")
assert.Assert(c, err, checker.IsNil, check.Commentf("could not create temp file for config reload"))
assert.Assert(c, err == nil, check.Commentf("could not create temp file for config reload"))
defer os.RemoveAll(configPath) // clean up
configFile := filepath.Join(configPath, "config.json")
size := 67108864 * 2
configData := []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
assert.Assert(c, ioutil.WriteFile(configFile, configData, 0666), checker.IsNil, check.Commentf("could not write temp file for config reload"))
assert.Assert(c, ioutil.WriteFile(configFile, configData, 0666) == nil, check.Commentf("could not write temp file for config reload"))
pattern := regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
s.d.StartWithBusybox(c, "--config-file", configFile)
@ -2876,11 +2876,11 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
size = 67108864 * 3
configData = []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
assert.Assert(c, ioutil.WriteFile(configFile, configData, 0666), checker.IsNil, check.Commentf("could not write temp file for config reload"))
assert.Assert(c, ioutil.WriteFile(configFile, configData, 0666) == nil, check.Commentf("could not write temp file for config reload"))
pattern = regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
err = s.d.ReloadConfig()
assert.Assert(c, err, checker.IsNil, check.Commentf("error reloading daemon config"))
assert.Assert(c, err == nil, check.Commentf("error reloading daemon config"))
name = "shm2"
out, err = s.d.Cmd("run", "--name", name, "busybox", "mount")

View File

@ -382,10 +382,10 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *
cmd1 := exec.Command(dockerBinary, "volume", "create", "-d", "down-driver")
cmd2 := exec.Command(dockerBinary, "volume", "create")
assert.Assert(c, cmd1.Start(), checker.IsNil)
assert.Assert(c, cmd1.Start() == nil)
defer cmd1.Process.Kill()
time.Sleep(100 * time.Millisecond) // ensure API has been called
assert.Assert(c, cmd2.Start(), checker.IsNil)
assert.Assert(c, cmd2.Start() == nil)
go func() {
cmd1.Wait()
@ -453,7 +453,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c
Driver string
}
out := inspectFieldJSON(c, "testing", "Mounts")
assert.Assert(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts), checker.IsNil)
assert.Assert(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts) == nil)
assert.Equal(c, len(mounts), 1, check.Commentf("%s", out))
assert.Equal(c, mounts[0].Name, "foo")
assert.Equal(c, mounts[0].Driver, volumePluginName)
@ -487,7 +487,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) {
}
var st []vol
assert.Assert(c, json.Unmarshal([]byte(out), &st), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &st) == nil)
assert.Equal(c, len(st), 1)
assert.Equal(c, len(st[0].Status), 1, check.Commentf("%v", st[0]))
assert.Equal(c, st[0].Status["Hello"], "world", check.Commentf("%v", st[0].Status))

View File

@ -113,7 +113,7 @@ func (s *DockerSuite) TestHealth(c *testing.T) {
failsStr, _ := dockerCmd(c, "inspect", "--format={{.State.Health.FailingStreak}}", "fatal_healthcheck")
fails, err := strconv.Atoi(strings.TrimSpace(failsStr))
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
assert.Equal(c, fails >= 3, true)
dockerCmd(c, "rm", "-f", "fatal_healthcheck")

View File

@ -97,7 +97,7 @@ func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) {
sizeString := lines[i][startIndex:endIndex]
_, err := strconv.Atoi(strings.TrimSpace(sizeString))
assert.Assert(c, err, checker.IsNil, check.Commentf("The size '%s' was not an Integer", sizeString))
assert.Assert(c, err == nil, check.Commentf("The size '%s' was not an Integer", sizeString))
}
}

View File

@ -50,7 +50,7 @@ func (s *DockerSuite) TestImportFile(c *testing.T) {
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create temporary file"))
assert.Assert(c, err == nil, check.Commentf("failed to create temporary file"))
defer os.Remove(temporaryFile.Name())
icmd.RunCmd(icmd.Cmd{
@ -71,7 +71,7 @@ func (s *DockerSuite) TestImportGzipped(c *testing.T) {
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create temporary file"))
assert.Assert(c, err == nil, check.Commentf("failed to create temporary file"))
defer os.Remove(temporaryFile.Name())
w := gzip.NewWriter(temporaryFile)
@ -79,7 +79,7 @@ func (s *DockerSuite) TestImportGzipped(c *testing.T) {
Command: []string{dockerBinary, "export", "test-import"},
Stdout: w,
}).Assert(c, icmd.Success)
assert.Assert(c, w.Close(), checker.IsNil, check.Commentf("failed to close gzip writer"))
assert.Assert(c, w.Close() == nil, check.Commentf("failed to close gzip writer"))
temporaryFile.Close()
out, _ := dockerCmd(c, "import", temporaryFile.Name())
assert.Assert(c, strings.Count(out, "\n") == 1, "display is expected 1 '\\n' but didn't")
@ -94,7 +94,7 @@ func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) {
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create temporary file"))
assert.Assert(c, err == nil, check.Commentf("failed to create temporary file"))
defer os.Remove(temporaryFile.Name())
icmd.RunCmd(icmd.Cmd{
@ -130,7 +130,7 @@ func (s *DockerSuite) TestImportWithQuotedChanges(c *testing.T) {
cli.DockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create temporary file"))
assert.Assert(c, err == nil, check.Commentf("failed to create temporary file"))
defer os.Remove(temporaryFile.Name())
cli.Docker(cli.Args("export", "test-import"), cli.WithStdout(bufio.NewWriter(temporaryFile))).Assert(c, icmd.Success)

View File

@ -130,7 +130,7 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) {
out := inspectField(c, imageTest, "Size")
size, err := strconv.Atoi(out)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect size of the image: %s, %v", out, err))
assert.Assert(c, err == nil, check.Commentf("failed to inspect size of the image: %s, %v", out, err))
//now see if the size turns out to be the same
formatStr := fmt.Sprintf("--format={{eq .Size %d}}", size)
@ -152,7 +152,7 @@ func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) {
out = inspectField(c, id, "State.ExitCode")
exitCode, err := strconv.Atoi(out)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect exitcode of the container: %s, %v", out, err))
assert.Assert(c, err == nil, check.Commentf("failed to inspect exitcode of the container: %s, %v", out, err))
//now get the exit code to verify
formatStr := fmt.Sprintf("--format={{eq .State.ExitCode %d}}", exitCode)
@ -172,12 +172,12 @@ func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) {
deviceID := inspectField(c, imageTest, "GraphDriver.Data.DeviceId")
_, err := strconv.Atoi(deviceID)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceId of the image: %s, %v", deviceID, err))
assert.Assert(c, err == nil, check.Commentf("failed to inspect DeviceId of the image: %s, %v", deviceID, err))
deviceSize := inspectField(c, imageTest, "GraphDriver.Data.DeviceSize")
_, err = strconv.ParseUint(deviceSize, 10, 64)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
assert.Assert(c, err == nil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
}
func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) {
@ -197,12 +197,12 @@ func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) {
assert.Assert(c, imageDeviceID != deviceID)
_, err := strconv.Atoi(deviceID)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceId of the image: %s, %v", deviceID, err))
assert.Assert(c, err == nil, check.Commentf("failed to inspect DeviceId of the image: %s, %v", deviceID, err))
deviceSize := inspectField(c, out, "GraphDriver.Data.DeviceSize")
_, err = strconv.ParseUint(deviceSize, 10, 64)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
assert.Assert(c, err == nil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
}
func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) {
@ -289,7 +289,7 @@ func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) {
out := inspectFieldJSON(c, "test", "HostConfig.LogConfig")
err := json.NewDecoder(strings.NewReader(out)).Decode(&logConfig)
assert.Assert(c, err, checker.IsNil, check.Commentf("%v", out))
assert.Assert(c, err == nil, check.Commentf("%v", out))
assert.Equal(c, logConfig.Type, "json-file")
assert.Equal(c, logConfig.Config["max-file"], "42", check.Commentf("%v", logConfig))

View File

@ -148,7 +148,7 @@ func (s *DockerSuite) TestLinksHostsFilesInject(c *testing.T) {
out, _ = dockerCmd(c, "run", "-itd", "--name", "two", "--link", "one:onetwo", "busybox", "top")
idTwo := strings.TrimSpace(out)
assert.Assert(c, waitRun(idTwo), checker.IsNil)
assert.Assert(c, waitRun(idTwo) == nil)
readContainerFileWithExec(c, idOne, "/etc/hosts")
contentTwo := readContainerFileWithExec(c, idTwo, "/etc/hosts")
@ -203,12 +203,12 @@ func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "--name", "shortlinkdef", "busybox", "top")
cid := strings.TrimSpace(out)
assert.Assert(c, waitRun(cid), checker.IsNil)
assert.Assert(c, waitRun(cid) == nil)
out, _ = dockerCmd(c, "run", "-d", "--name", "link2", "--link", "shortlinkdef", "busybox", "top")
cid2 := strings.TrimSpace(out)
assert.Assert(c, waitRun(cid2), checker.IsNil)
assert.Assert(c, waitRun(cid2) == nil)
links := inspectFieldJSON(c, cid2, "HostConfig.Links")
assert.Equal(c, links, "[\"/shortlinkdef:/link2/shortlinkdef\"]")

View File

@ -505,7 +505,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *testing.T) {
}()
out, _ := dockerCmd(c, "run", "-d", "--name", "testNetInspect1", "--net", "brNetForInspect", "busybox", "top")
assert.Assert(c, waitRun("testNetInspect1"), checker.IsNil)
assert.Assert(c, waitRun("testNetInspect1") == nil)
containerID := strings.TrimSpace(out)
defer func() {
// we don't stop container by name, because we'll rename it later
@ -546,7 +546,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) {
// run a container
out, _ := dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
assert.Assert(c, waitRun("test"), checker.IsNil)
assert.Assert(c, waitRun("test") == nil)
containerID := strings.TrimSpace(out)
// connect the container to the test network
@ -570,7 +570,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) {
// run another container
out, _ = dockerCmd(c, "run", "-d", "--net", "test", "--name", "test2", "busybox", "top")
assert.Assert(c, waitRun("test2"), checker.IsNil)
assert.Assert(c, waitRun("test2") == nil)
containerID = strings.TrimSpace(out)
nr = getNwResource(c, "test")
@ -974,7 +974,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing
assert.NilError(c, err)
// Kill daemon and restart
assert.Assert(c, s.d.Kill(), checker.IsNil)
assert.Assert(c, s.d.Kill() == nil)
server.Close()
@ -1094,7 +1094,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRe
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList)
// Kill daemon and restart
assert.Assert(c, s.d.Kill(), checker.IsNil)
assert.Assert(c, s.d.Kill() == nil)
s.d.Restart(c)
// Restart container
@ -1107,7 +1107,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRe
func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *testing.T) {
out, _ := dockerCmd(c, "network", "create", "one")
containerOut, _, err := dockerCmdWithError("run", "-d", "--net", strings.TrimSpace(out), "busybox", "top")
assert.Assert(c, err, checker.IsNil, check.Commentf(containerOut))
assert.Assert(c, err == nil, check.Commentf(containerOut))
}
func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *testing.T) {
@ -1126,7 +1126,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
}
// Kill daemon ungracefully and restart
assert.Assert(c, s.d.Kill(), checker.IsNil)
assert.Assert(c, s.d.Kill() == nil)
s.d.Restart(c)
// make sure all the containers are up and running
@ -1138,7 +1138,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
assert.Assert(c, waitRun("container1"), checker.IsNil)
assert.Assert(c, waitRun("container1") == nil)
dockerCmd(c, "network", "disconnect", "bridge", "container1")
out, _, err := dockerCmdWithError("network", "connect", "host", "container1")
assert.ErrorContains(c, err, "", out)
@ -1147,7 +1147,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *t
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", "container1", "--net=host", "busybox", "top")
assert.Assert(c, waitRun("container1"), checker.IsNil)
assert.Assert(c, waitRun("container1") == nil)
out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1")
assert.Assert(c, err, checker.NotNil, check.Commentf("Should err out disconnect from host"))
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
@ -1157,7 +1157,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing.
testRequires(c, NotArm)
dockerCmd(c, "network", "create", "test1")
dockerCmd(c, "run", "-d", "--name", "c1", "-p", "5000:5000", "busybox", "top")
assert.Assert(c, waitRun("c1"), checker.IsNil)
assert.Assert(c, waitRun("c1") == nil)
dockerCmd(c, "network", "connect", "test1", "c1")
}
@ -1181,7 +1181,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c
dockerCmd(c, "network", "create", "ccc")
dockerCmd(c, "run", "-d", "--name", cnt, "-p", "9000:90", "-p", "70", "busybox", "top")
assert.Assert(c, waitRun(cnt), checker.IsNil)
assert.Assert(c, waitRun(cnt) == nil)
curPortMap, _ := dockerCmd(c, "port", cnt, "70")
curExplPortMap, _ := dockerCmd(c, "port", cnt, "90")
@ -1211,7 +1211,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *testing.T) {
macAddress := "02:42:ac:11:00:02"
dockerCmd(c, "network", "create", "mynetwork")
dockerCmd(c, "run", "--name=test", "-d", "--mac-address", macAddress, "busybox", "top")
assert.Assert(c, waitRun("test"), checker.IsNil)
assert.Assert(c, waitRun("test") == nil)
mac1 := inspectField(c, "test", "NetworkSettings.Networks.bridge.MacAddress")
assert.Equal(c, strings.TrimSpace(mac1), macAddress)
dockerCmd(c, "network", "connect", "mynetwork", "test")
@ -1228,7 +1228,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCreatedContainer(c *testing
func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *testing.T) {
dockerCmd(c, "network", "create", "test")
dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top")
assert.Assert(c, waitRun("foo"), checker.IsNil)
assert.Assert(c, waitRun("foo") == nil)
dockerCmd(c, "network", "connect", "test", "foo")
dockerCmd(c, "restart", "foo")
networks := inspectField(c, "foo", "NetworkSettings.Networks")
@ -1251,7 +1251,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine
// start the container and test if we can ping it from another container in the same network
dockerCmd(c, "start", "foo")
assert.Assert(c, waitRun("foo"), checker.IsNil)
assert.Assert(c, waitRun("foo") == nil)
ip := inspectField(c, "foo", "NetworkSettings.Networks.test.IPAddress")
ip = strings.TrimSpace(ip)
dockerCmd(c, "run", "--net=test", "busybox", "sh", "-c", fmt.Sprintf("ping -c 1 %s", ip))
@ -1296,7 +1296,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
// run a container on first network specifying the ip addresses
dockerCmd(c, "run", "-d", "--name", "c0", "--net=n0", "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
assert.Assert(c, waitRun("c0"), checker.IsNil)
assert.Assert(c, waitRun("c0") == nil)
verifyIPAddressConfig(c, "c0", "n0", "172.28.99.88", "2001:db8:1234::9988")
verifyIPAddresses(c, "c0", "n0", "172.28.99.88", "2001:db8:1234::9988")
@ -1336,7 +1336,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer
// start the container, verify config has not changed and ip addresses are assigned
dockerCmd(c, "start", "c0")
assert.Assert(c, waitRun("c0"), checker.IsNil)
assert.Assert(c, waitRun("c0") == nil)
verifyIPAddressConfig(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544")
verifyIPAddresses(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544")
@ -1406,13 +1406,13 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) {
// run two containers with link-local ip on the test network
dockerCmd(c, "run", "-d", "--name", "c0", "--net=n0", "--link-local-ip", "169.254.7.7", "--link-local-ip", "fe80::254:77", "busybox", "top")
assert.Assert(c, waitRun("c0"), checker.IsNil)
assert.Assert(c, waitRun("c0") == nil)
dockerCmd(c, "run", "-d", "--name", "c1", "--net=n0", "--link-local-ip", "169.254.8.8", "--link-local-ip", "fe80::254:88", "busybox", "top")
assert.Assert(c, waitRun("c1"), checker.IsNil)
assert.Assert(c, waitRun("c1") == nil)
// run a container on the default network and connect it to the test network specifying a link-local address
dockerCmd(c, "run", "-d", "--name", "c2", "busybox", "top")
assert.Assert(c, waitRun("c2"), checker.IsNil)
assert.Assert(c, waitRun("c2") == nil)
dockerCmd(c, "network", "connect", "--link-local-ip", "169.254.9.9", "n0", "c2")
// verify the three containers can ping each other via the link-local addresses
@ -1446,13 +1446,13 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *testing.T)
dockerCmd(c, "network", "create", "-d", "bridge", "foo2")
dockerCmd(c, "run", "-d", "--net=foo1", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// run a container in a user-defined network with a link for an existing container
// and a link for a container that doesn't exist
dockerCmd(c, "run", "-d", "--net=foo1", "--name=second", "--link=first:FirstInFoo1",
"--link=third:bar", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias FirstInFoo1 must succeed
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -1494,7 +1494,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *testing.T) {
dockerCmd(c, "network", "disconnect", "bridge", containerName)
dockerCmd(c, "start", containerName)
assert.Assert(c, waitRun(containerName), checker.IsNil)
assert.Assert(c, waitRun(containerName) == nil)
networks := inspectField(c, containerName, "NetworkSettings.Networks")
assert.Assert(c, networks, checker.Contains, netWorkName1, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName1)))
assert.Assert(c, networks, checker.Contains, netWorkName2, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName2)))
@ -1520,10 +1520,10 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T)
dockerCmd(c, "network", "create", "-d", "bridge", "net2")
cid, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=first", "--net-alias=foo", "busybox:glibc", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// ping first container and its alias
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -1574,10 +1574,10 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "br.net1")
dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c1.net1", "busybox:glibc", "top")
assert.Assert(c, waitRun("c1.net1"), checker.IsNil)
assert.Assert(c, waitRun("c1.net1") == nil)
dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c2.net1", "busybox:glibc", "top")
assert.Assert(c, waitRun("c2.net1"), checker.IsNil)
assert.Assert(c, waitRun("c2.net1") == nil)
// ping first container by its unqualified name
_, _, err := dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1")
@ -1602,7 +1602,7 @@ func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *testing.T) {
func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T) {
dockerCmd(c, "run", "-d", "--name=bb", "busybox", "top")
assert.Assert(c, waitRun("bb"), checker.IsNil)
assert.Assert(c, waitRun("bb") == nil)
defer dockerCmd(c, "stop", "bb")
ns0 := inspectField(c, "bb", "NetworkSettings.Networks.bridge")
@ -1622,9 +1622,9 @@ func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) {
assert.Assert(c, nr.Internal, checker.True)
dockerCmd(c, "run", "-d", "--net=internal", "--name=first", "busybox:glibc", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=internal", "--name=second", "busybox:glibc", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
out, _, err := dockerCmdWithError("exec", "first", "ping", "-W", "4", "-c", "1", "8.8.8.8")
assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "100% packet loss")
@ -1733,7 +1733,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *testing.T) {
_, _, err = dockerCmdWithError("run", "-d", "--name", "mynet0", "--net=mynet", "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
assert.NilError(c, err)
assert.Assert(c, waitRun("mynet0"), checker.IsNil)
assert.Assert(c, waitRun("mynet0") == nil)
verifyIPAddressConfig(c, "mynet0", "mynet", "172.28.99.88", "2001:db8:1234::9988")
verifyIPAddresses(c, "mynet0", "mynet", "172.28.99.88", "2001:db8:1234::9988")

View File

@ -180,7 +180,7 @@ func (ps *DockerPluginSuite) TestPluginSet(c *testing.T) {
{Name: "pdev2", Settable: []string{"path"}}, // Device without Path is invalid.
}
})
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create test plugin"))
assert.Assert(c, err == nil, check.Commentf("failed to create test plugin"))
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name)
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=0]")
@ -363,7 +363,7 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
})
cancel()
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create test plugin"))
assert.Assert(c, err == nil, check.Commentf("failed to create test plugin"))
// Find ID first
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", name)
@ -425,7 +425,7 @@ func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {
err = plugin.Create(ctx, client, name, func(cfg *plugin.Config) {
cfg.Description = "test plugin"
})
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create test plugin"))
assert.Assert(c, err == nil, check.Commentf("failed to create test plugin"))
out, _ := dockerCmd(c, "plugin", "inspect", "--format", "{{.ID}}", name)
id := strings.TrimSpace(out)
@ -480,7 +480,7 @@ func (s *DockerSuite) TestPluginMetricsCollector(c *testing.T) {
name := "cpuguy83/docker-metrics-plugin-test:latest"
r := cli.Docker(cli.Args("plugin", "install", "--grant-all-permissions", name), cli.Daemon(d))
assert.Assert(c, r.Error, checker.IsNil, check.Commentf(r.Combined()))
assert.Assert(c, r.Error == nil, check.Commentf(r.Combined()))
// plugin lisens on localhost:19393 and proxies the metrics
resp, err := http.Get("http://localhost:19393/metrics")

View File

@ -314,7 +314,7 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) {
out, _ = dockerCmd(c, "port", firstID, "80")
_, exposedPort, err := net.SplitHostPort(out)
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %s", out))
assert.Assert(c, err == nil, check.Commentf("out: %s", out))
dockerCmd(c, "run", "--net=host", "busybox",
"nc", "localhost", strings.TrimSpace(exposedPort))
@ -335,7 +335,7 @@ func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
dockerCmd(c, "run", "--net", "internal-net", "-d", "--name", "c1",
"-p", "8080:8080", "busybox", "nc", "-l", "-p", "8080")
assert.Assert(c, waitRun("c1"), checker.IsNil)
assert.Assert(c, waitRun("c1") == nil)
_, _, err := dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080")
assert.Assert(c, err, checker.NotNil, check.Commentf("Port mapping on internal network is expected to fail"))
@ -344,5 +344,5 @@ func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
dockerCmd(c, "network", "connect", "foo-net", "c1")
_, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080")
assert.Assert(c, err, checker.IsNil, check.Commentf("Port mapping on the new network is expected to succeed"))
assert.Assert(c, err == nil, check.Commentf("Port mapping on the new network is expected to succeed"))
}

View File

@ -35,13 +35,13 @@ func (s *DockerSuite) TestPsListContainersBase(c *testing.T) {
fourthID := strings.TrimSpace(out)
// make sure the second is running
assert.Assert(c, waitRun(secondID), checker.IsNil)
assert.Assert(c, waitRun(secondID) == nil)
// make sure third one is not running
dockerCmd(c, "wait", thirdID)
// make sure the forth is running
assert.Assert(c, waitRun(fourthID), checker.IsNil)
assert.Assert(c, waitRun(fourthID) == nil)
// all
out, _ = dockerCmd(c, "ps", "-a")
@ -593,7 +593,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top")
assert.Assert(c, waitRun("foo"), checker.IsNil)
assert.Assert(c, waitRun("foo") == nil)
out, _ := dockerCmd(c, "ps")
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
expected := "0.0.0.0:5000->5000/tcp"
@ -618,9 +618,9 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
dockerCmd(c, "volume", "create", "ps-volume-test")
// volume mount containers
runSleepingContainer(c, "--name=volume-test-1", "--volume", "ps-volume-test:"+mp)
assert.Assert(c, waitRun("volume-test-1"), checker.IsNil)
assert.Assert(c, waitRun("volume-test-1") == nil)
runSleepingContainer(c, "--name=volume-test-2", "--volume", mp)
assert.Assert(c, waitRun("volume-test-2"), checker.IsNil)
assert.Assert(c, waitRun("volume-test-2") == nil)
// bind mount container
var bindMountSource string
var bindMountDestination string
@ -632,7 +632,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
bindMountDestination = "/t"
}
runSleepingContainer(c, "--name=bind-mount-test", "-v", bindMountSource+":"+bindMountDestination)
assert.Assert(c, waitRun("bind-mount-test"), checker.IsNil)
assert.Assert(c, waitRun("bind-mount-test") == nil)
out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}")

View File

@ -340,10 +340,10 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
// Add to revision store
revisionDir := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "revisions", "sha256", hexDigest)
err = os.Mkdir(revisionDir, 0755)
assert.Assert(c, err, checker.IsNil, check.Commentf("error creating revision dir"))
assert.Assert(c, err == nil, check.Commentf("error creating revision dir"))
revisionPath := filepath.Join(revisionDir, "link")
err = ioutil.WriteFile(revisionPath, []byte(manifestListDigest.String()), 0644)
assert.Assert(c, err, checker.IsNil, check.Commentf("error writing revision link"))
assert.Assert(c, err == nil, check.Commentf("error writing revision link"))
// Update tag
tagPath := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "tags", "latest", "current", "link")

View File

@ -211,13 +211,13 @@ func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet")
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// run a container in user-defined network udlinkNet with a link for an existing container
// and a link for a container that doesn't exist
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=second", "--link=first:foo",
"--link=third:bar", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias foo must succeed
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -233,7 +233,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) {
// start third container now
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=third", "busybox", "top")
assert.Assert(c, waitRun("third"), checker.IsNil)
assert.Assert(c, waitRun("third") == nil)
// ping to third and its alias must succeed now
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "third")
@ -247,11 +247,11 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet")
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=second", "--link=first:foo",
"busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias foo must succeed
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -261,7 +261,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) {
// Restart first container
dockerCmd(c, "restart", "first")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// ping to first and its alias foo must still succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -271,7 +271,7 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) {
// Restart second container
dockerCmd(c, "restart", "second")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias foo must still succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -296,7 +296,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
cid1, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=first", "--net-alias=foo1", "--net-alias=foo2", "busybox:glibc", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// Check if default short-id alias is added automatically
id := strings.TrimSpace(cid1)
@ -304,7 +304,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) {
assert.Assert(c, aliases, checker.Contains, stringid.TruncateID(id))
cid2, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Check if default short-id alias is added automatically
id = strings.TrimSpace(cid2)
@ -324,7 +324,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) {
// Restart first container
dockerCmd(c, "restart", "first")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// ping to first and its network-scoped aliases must succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@ -2815,7 +2815,7 @@ func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
name := "ibuildthecloud"
dockerCmd(c, "run", "-d", "--pid=host", "--name", name, "busybox", "sh", "-c", "sleep 30; echo hi")
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
errchan := make(chan error)
go func() {
@ -3466,7 +3466,7 @@ func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork")
dockerCmd(c, "run", "-d", "--net=testnetwork", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-t", "--net=testnetwork", "--name=second", "busybox", "ping", "-c", "1", "first")
}
@ -3477,9 +3477,9 @@ func (s *DockerSuite) TestContainersInMultipleNetworks(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
// Run and connect containers to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Check connectivity between containers in testnetwork2
dockerCmd(c, "exec", "first", "ping", "-c", "1", "second.testnetwork1")
// Connect containers to testnetwork2
@ -3496,9 +3496,9 @@ func (s *DockerSuite) TestContainersNetworkIsolation(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
// Run 1 container in testnetwork1 and another in testnetwork2
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork2", "--name=second", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Check Isolation between containers : ping must fail
_, _, err := dockerCmdWithError("exec", "first", "ping", "-c", "1", "second")
@ -3522,9 +3522,9 @@ func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *testing.T) {
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
// Run and connect containers to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Network delete with active containers must fail
_, _, err := dockerCmdWithError("network", "rm", "testnetwork1")
assert.ErrorContains(c, err, "")
@ -3542,9 +3542,9 @@ func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *testing.T) {
// Run and connect containers to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Check connectivity between containers in testnetwork2
dockerCmd(c, "exec", "first", "ping", "-c", "1", "second.testnetwork1")
// Connect containers to testnetwork2
@ -3570,7 +3570,7 @@ func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
// Run a container with --net=host
dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// Create a network using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@ -3583,10 +3583,10 @@ func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) {
func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// Run second container in first container's network namespace
dockerCmd(c, "run", "-d", "--net=container:first", "--name=second", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Create a network using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@ -3600,7 +3600,7 @@ func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) {
func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--net=none", "--name=first", "busybox", "top")
assert.Assert(c, waitRun("first"), checker.IsNil)
assert.Assert(c, waitRun("first") == nil)
// Create a network using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@ -3612,7 +3612,7 @@ func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) {
// create a container connected to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
assert.Assert(c, waitRun("second"), checker.IsNil)
assert.Assert(c, waitRun("second") == nil)
// Connect second container to none network. it must fail as well
_, _, err = dockerCmdWithError("network", "connect", "none", "second")
@ -3628,7 +3628,7 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) {
stdout := bytes.NewBuffer(nil)
cmd.Stdout = stdout
cmd.Stderr = stdout
assert.Assert(c, cmd.Start(), checker.IsNil)
assert.Assert(c, cmd.Start() == nil)
waitChan := make(chan error)
go func() {
@ -3637,7 +3637,7 @@ func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) {
select {
case err := <-waitChan:
assert.Assert(c, err, checker.IsNil, check.Commentf(stdout.String()))
assert.Assert(c, err == nil, check.Commentf(stdout.String()))
case <-time.After(30 * time.Second):
c.Fatal("timeout waiting for command to exit")
}
@ -3944,7 +3944,7 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
runSleepingContainer(c, "--name=test", "-p", "8000:8000")
// Wait until container is fully up and running
assert.Assert(c, waitRun("test"), checker.IsNil)
assert.Assert(c, waitRun("test") == nil)
out, _, err := dockerCmdWithError("run", "--name=fail", "-p", "8000:8000", "busybox", "true")
// We will need the following `inspect` to diagnose the issue if test fails (#21247)
@ -3961,7 +3961,7 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
dockerCmd(c, "rm", "-f", "test")
// NGoroutines is not updated right away, so we need to wait before failing
assert.Assert(c, waitForGoroutines(nroutines), checker.IsNil)
assert.Assert(c, waitForGoroutines(nroutines) == nil)
}
// Test for one character directory name case (#20122)
@ -4054,7 +4054,7 @@ 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, checker.IsNil, check.Commentf("out: %s; exit code: %d", out, code))
assert.Assert(c, err == nil, check.Commentf("out: %s; exit code: %d", out, code))
assert.Equal(c, out, "2\n", "exit code: %d", code)
assert.Equal(c, code, 0)
}
@ -4144,7 +4144,7 @@ func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) {
assert.Assert(c, out, checker.Contains, "failed to initialize logging driver", check.Commentf("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), checker.IsNil)
assert.Assert(c, waitForGoroutines(nroutines) == nil)
}
// Handles error conditions for --credentialspec. Validating E2E success cases
@ -4497,8 +4497,8 @@ 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, checker.IsNil, check.Commentf("got error while creating a container with %v (%s)", opts, cName))
assert.Assert(c, testCase.fn(cName), checker.IsNil, check.Commentf("got error while executing test for %v (%s)", opts, cName))
assert.Assert(c, err == nil, check.Commentf("got error while creating a container with %v (%s)", opts, cName))
assert.Assert(c, testCase.fn(cName) == nil, check.Commentf("got error while executing test for %v (%s)", opts, cName))
dockerCmd(c, "rm", "-f", cName)
} else {
assert.Assert(c, err, checker.NotNil, check.Commentf("got nil while creating a container with %v (%s)", opts, cName))

View File

@ -35,7 +35,7 @@ import (
func (s *DockerSuite) TestRunRedirectStdout(c *testing.T) {
checkRedirect := func(command string) {
_, tty, err := pty.Open()
assert.Assert(c, err, checker.IsNil, check.Commentf("Could not open pty"))
assert.Assert(c, err == nil, check.Commentf("Could not open pty"))
cmd := exec.Command("sh", "-c", command)
cmd.Stdin = tty
cmd.Stdout = tty
@ -51,7 +51,7 @@ func (s *DockerSuite) TestRunRedirectStdout(c *testing.T) {
case <-time.After(10 * time.Second):
c.Fatal("command timeout")
case err := <-ch:
assert.Assert(c, err, checker.IsNil, check.Commentf("wait err"))
assert.Assert(c, err == nil, check.Commentf("wait err"))
}
}
@ -70,8 +70,8 @@ func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *testing.T) {
// Create a temporary tmpfs mount.
tmpfsDir := filepath.Join(tmpDir, "tmpfs")
assert.Assert(c, os.MkdirAll(tmpfsDir, 0777), checker.IsNil, check.Commentf("failed to mkdir at %s", tmpfsDir))
assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", ""), checker.IsNil, check.Commentf("failed to create a tmpfs mount at %s", tmpfsDir))
assert.Assert(c, os.MkdirAll(tmpfsDir, 0777) == nil, check.Commentf("failed to mkdir at %s", tmpfsDir))
assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, check.Commentf("failed to create a tmpfs mount at %s", tmpfsDir))
f, err := ioutil.TempFile(tmpfsDir, "touch-me")
assert.NilError(c, err)
@ -108,7 +108,7 @@ func (s *DockerSuite) TestRunAttachDetach(c *testing.T) {
defer cpty.Close()
cmd.Stdin = tty
assert.NilError(c, cmd.Start())
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
_, err = cpty.Write([]byte("hello\n"))
assert.NilError(c, err)
@ -167,7 +167,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) {
if err := cmd.Start(); err != nil {
c.Fatal(err)
}
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
c.Fatal(err)
@ -210,7 +210,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) {
func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *testing.T) {
name := "attach-detach"
dockerCmd(c, "run", "--name", name, "-itd", "busybox", "top")
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
// specify an invalid detach key, container will ignore it and use default
cmd := exec.Command(dockerBinary, "attach", "--detach-keys=ctrl-A,a", name)
@ -283,7 +283,7 @@ func (s *DockerSuite) TestRunAttachDetachFromConfig(c *testing.T) {
if err := cmd.Start(); err != nil {
c.Fatal(err)
}
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
c.Fatal(err)
@ -366,7 +366,7 @@ func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) {
if err := cmd.Start(); err != nil {
c.Fatal(err)
}
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
c.Fatal(err)
@ -427,7 +427,7 @@ func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.
c.Fatal(err)
}
go cmd.Wait()
assert.Assert(c, waitRun(name), checker.IsNil)
assert.Assert(c, waitRun(name) == nil)
// Invalid escape sequence aba, should print aba in output
if _, err := cpty.Write(keyA); err != nil {
@ -709,7 +709,7 @@ func (s *DockerSuite) TestStopContainerSignal(c *testing.T) {
out, _ := dockerCmd(c, "run", "--stop-signal", "SIGUSR1", "-d", "busybox", "/bin/sh", "-c", `trap 'echo "exit trapped"; exit 0' USR1; while true; do sleep 1; done`)
containerID := strings.TrimSpace(out)
assert.Assert(c, waitRun(containerID), checker.IsNil)
assert.Assert(c, waitRun(containerID) == nil)
dockerCmd(c, "stop", containerID)
out, _ = dockerCmd(c, "logs", containerID)

View File

@ -137,13 +137,13 @@ func (s *DockerSuite) TestSaveImageId(c *testing.T) {
var err error
tarCmd.Stdin, err = saveCmd.StdoutPipe()
assert.Assert(c, err, checker.IsNil, check.Commentf("cannot set stdout pipe for tar: %v", err))
assert.Assert(c, err == nil, check.Commentf("cannot set stdout pipe for tar: %v", err))
grepCmd := exec.Command("grep", cleanedLongImageID)
grepCmd.Stdin, err = tarCmd.StdoutPipe()
assert.Assert(c, err, checker.IsNil, check.Commentf("cannot set stdout pipe for grep: %v", err))
assert.Assert(c, err == nil, check.Commentf("cannot set stdout pipe for grep: %v", err))
assert.Assert(c, tarCmd.Start(), checker.IsNil, check.Commentf("tar failed with error: %v", err))
assert.Assert(c, saveCmd.Start(), checker.IsNil, check.Commentf("docker save failed with error: %v", err))
assert.Assert(c, tarCmd.Start() == nil, check.Commentf("tar failed with error: %v", err))
assert.Assert(c, saveCmd.Start() == nil, check.Commentf("docker save failed with error: %v", err))
defer func() {
saveCmd.Wait()
tarCmd.Wait()
@ -152,7 +152,7 @@ func (s *DockerSuite) TestSaveImageId(c *testing.T) {
out, _, err = runCommandWithOutput(grepCmd)
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to save repo with image ID: %s, %v", out, err))
assert.Assert(c, err == nil, check.Commentf("failed to save repo with image ID: %s, %v", out, err))
}
// save a repo and try to load it using flags
@ -264,7 +264,7 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *testing.T) {
name := "save-directory-permissions"
tmpDir, err := ioutil.TempDir("", "save-layers-with-directories")
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to create temporary directory: %s", err))
assert.Assert(c, err == nil, check.Commentf("failed to create temporary directory: %s", err))
extractionDirectory := filepath.Join(tmpDir, "image-extraction-dir")
os.Mkdir(extractionDirectory, 0777)

View File

@ -41,7 +41,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
assert.NilError(c, err, out)
var mountConfig []mount.Mount
assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig) == nil)
assert.Equal(c, len(mountConfig), 1)
assert.Equal(c, mountConfig[0].Source, "foo")
@ -55,7 +55,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
assert.NilError(c, err, out)
var mounts []types.MountPoint
assert.Assert(c, json.Unmarshal([]byte(out), &mounts), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &mounts) == nil)
assert.Equal(c, len(mounts), 1)
assert.Equal(c, mounts[0].Type, mount.TypeVolume)
@ -84,7 +84,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *testing.T) {
assert.NilError(c, err)
var refs []swarm.SecretReference
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 1)
assert.Equal(c, refs[0].SecretName, testName)
@ -133,7 +133,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testi
assert.NilError(c, err)
var refs []swarm.SecretReference
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), len(testPaths))
var tasks []swarm.Task
@ -183,7 +183,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing
assert.NilError(c, err)
var refs []swarm.SecretReference
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 2)
var tasks []swarm.Task
@ -232,7 +232,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *testing.T) {
assert.NilError(c, err)
var refs []swarm.ConfigReference
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 1)
assert.Equal(c, refs[0].ConfigName, testName)
@ -280,7 +280,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi
assert.NilError(c, err)
var refs []swarm.ConfigReference
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), len(testPaths))
var tasks []swarm.Task
@ -330,7 +330,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing
assert.NilError(c, err)
var refs []swarm.ConfigReference
assert.Assert(c, json.Unmarshal([]byte(out), &refs), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 2)
var tasks []swarm.Task
@ -384,7 +384,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
assert.NilError(c, err, out)
var mountConfig []mount.Mount
assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig) == nil)
assert.Equal(c, len(mountConfig), 1)
assert.Equal(c, mountConfig[0].Source, "")
@ -398,7 +398,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
assert.NilError(c, err, out)
var mounts []types.MountPoint
assert.Assert(c, json.Unmarshal([]byte(out), &mounts), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &mounts) == nil)
assert.Equal(c, len(mounts), 1)
assert.Equal(c, mounts[0].Type, mount.TypeTmpfs)
@ -441,7 +441,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *testing.T) {
// Make sure the only alias seen is the container-id
var aliases []string
assert.Assert(c, json.Unmarshal([]byte(out), &aliases), checker.IsNil)
assert.Assert(c, json.Unmarshal([]byte(out), &aliases) == nil)
assert.Equal(c, len(aliases), 1)
assert.Assert(c, task.Status.ContainerStatus.ContainerID, checker.Contains, aliases[0])

View File

@ -117,7 +117,7 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
assert.Equal(c, spec.CAConfig.ExternalCAs[0].CACert, "")
assert.Equal(c, spec.CAConfig.ExternalCAs[1].CACert, string(expected))
assert.Assert(c, d.SwarmLeave(c, true), checker.IsNil)
assert.Assert(c, d.SwarmLeave(c, true) == nil)
cli.Docker(cli.Args("swarm", "init"), cli.Daemon(d)).Assert(c, icmd.Success)
spec = getSpec()
@ -171,7 +171,7 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *testing.T) {
func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *testing.T) {
d := s.AddDaemon(c, true, true)
hostname, err := d.Cmd("node", "inspect", "--format", "{{.Description.Hostname}}", "self")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", hostname))
assert.Assert(c, err == nil, check.Commentf("%s", hostname))
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "test", "--hostname", "{{.Service.Name}}-{{.Task.Slot}}-{{.Node.Hostname}}", "busybox", "top")
assert.NilError(c, err, out)
@ -431,7 +431,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *testing.T) {
assert.NilError(c, err, out)
// Leave the swarm
assert.Assert(c, d.SwarmLeave(c, true), checker.IsNil)
assert.Assert(c, d.SwarmLeave(c, true) == nil)
// Check the container is disconnected
out, err = d.Cmd("inspect", "c1", "--format", "{{.NetworkSettings.Networks."+nwName+"}}")
@ -1059,7 +1059,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
d := s.AddDaemon(c, false, false)
outs, err := d.Cmd("swarm", "init", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
unlockKey := getUnlockKey(d, c, outs)
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
@ -1084,16 +1084,16 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
outs, err = d.Cmd("node", "ls")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
outs, err = d.Cmd("swarm", "update", "--autolock=false")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
checkSwarmLockedToUnlocked(c, d)
outs, err = d.Cmd("node", "ls")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
}
@ -1101,7 +1101,7 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
d := s.AddDaemon(c, false, false)
outs, err := d.Cmd("swarm", "init", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
// It starts off locked
d.RestartNode(c)
@ -1118,13 +1118,13 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
// It is OK for user to leave a locked swarm with --force
outs, err = d.Cmd("swarm", "leave", "--force")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
info = d.SwarmInfo(c)
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive)
outs, err = d.Cmd("swarm", "init")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
info = d.SwarmInfo(c)
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
@ -1144,7 +1144,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
// enable autolock
outs, err := d1.Cmd("swarm", "update", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
unlockKey := getUnlockKey(d1, c, outs)
// The ones that got the cluster update should be set to locked
@ -1166,7 +1166,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
// leave it locked, and set the cluster to no longer autolock
outs, err = d1.Cmd("swarm", "update", "--autolock=false")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
// the ones that got the update are now set to unlocked
for _, d := range []*daemon.Daemon{d1, d3} {
@ -1196,7 +1196,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
// enable autolock
outs, err := d1.Cmd("swarm", "update", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
unlockKey := getUnlockKey(d1, c, outs)
// joined workers start off unlocked
@ -1254,13 +1254,13 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
d := s.AddDaemon(c, true, true)
outs, err := d.Cmd("swarm", "update", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
unlockKey := getUnlockKey(d, c, outs)
// Rotate multiple times
for i := 0; i != 3; i++ {
outs, err = d.Cmd("swarm", "unlock-key", "-q", "--rotate")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
// Strip \n
newUnlockKey := outs[:len(outs)-1]
assert.Assert(c, newUnlockKey != "")
@ -1343,13 +1343,13 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
d3 := s.AddDaemon(c, true, true)
outs, err := d1.Cmd("swarm", "update", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
unlockKey := getUnlockKey(d1, c, outs)
// Rotate multiple times
for i := 0; i != 3; i++ {
outs, err = d1.Cmd("swarm", "unlock-key", "-q", "--rotate")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
// Strip \n
newUnlockKey := outs[:len(outs)-1]
assert.Assert(c, newUnlockKey != "")
@ -1410,7 +1410,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
continue
}
}
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", outs))
assert.Assert(c, err == nil, check.Commentf("%s", outs))
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
break
}
@ -1426,7 +1426,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
for i := 0; i < 2; i++ {
// set to lock
outs, err := d.Cmd("swarm", "update", "--autolock")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
assert.Assert(c, outs, checker.Contains, "docker swarm unlock")
unlockKey := getUnlockKey(d, c, outs)
@ -1439,7 +1439,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
outs, err = d.Cmd("swarm", "update", "--autolock=false")
assert.Assert(c, err, checker.IsNil, check.Commentf("out: %v", outs))
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
checkSwarmLockedToUnlocked(c, d)
}
@ -2019,7 +2019,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *testing.T) {
func getUnlockKey(d *daemon.Daemon, c *testing.T, autolockOutput string) string {
unlockKey, err := d.Cmd("swarm", "unlock-key", "-q")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", unlockKey))
assert.Assert(c, err == nil, check.Commentf("%s", unlockKey))
unlockKey = strings.TrimSuffix(unlockKey, "\n")
// Check that "docker swarm init --autolock" or "docker swarm update --autolock"

View File

@ -60,7 +60,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
assert.Equal(c, statNotExists.GID(), uint32(gid), check.Commentf("Created directory not owned by remapped root GID"))
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
assert.Assert(c, err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid))
assert.Assert(c, err == nil, check.Commentf("Could not inspect running container: out: %q", pid))
// check the uid and gid maps for the PID to ensure root is remapped
// (cmd = cat /proc/<pid>/uid_map | grep -E '0\s+9999\s+1')
_, err = RunCommandPipelineWithOutput(
@ -81,7 +81,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
// use host usernamespace
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; top")
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out))
assert.Assert(c, err == nil, check.Commentf("Output: %s", out))
user = s.findUser(c, "userns_skip")
// userns are skipped, user is root
assert.Equal(c, user, "root")
@ -90,7 +90,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
// findUser finds the uid or name of the user of the first process that runs in a container
func (s *DockerDaemonSuite) findUser(c *testing.T, container string) string {
out, err := s.d.Cmd("top", container)
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out))
assert.Assert(c, err == nil, check.Commentf("Output: %s", out))
rows := strings.Split(out, "\n")
if len(rows) < 2 {
// No process rows founds

View File

@ -488,7 +488,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) {
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data2)
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-d", "busybox", "top")
assert.Assert(c, err, checker.IsNil, check.Commentf("Out: %s", out))
assert.Assert(c, err == nil, check.Commentf("Out: %s", out))
// Only the second volume will be referenced, this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")
@ -531,7 +531,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T
// /tmp/data is automatically created, because we are not using the modern mount API here
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-v", "/tmp/data:/tmp/data", "-d", "busybox", "top")
assert.Assert(c, err, checker.IsNil, check.Commentf("Out: %s", out))
assert.Assert(c, err == nil, check.Commentf("Out: %s", out))
// No volume will be referenced (mount is /tmp/data), this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")

View File

@ -70,7 +70,7 @@ func (s *DockerHubPullSuite) TearDownTest(c *testing.T) {
// output. The function fails the test when the command returns an error.
func (s *DockerHubPullSuite) Cmd(c *testing.T, name string, arg ...string) string {
out, err := s.CmdWithError(name, arg...)
assert.Assert(c, err, checker.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(arg, " "), out, err))
assert.Assert(c, err == nil, check.Commentf("%q failed with errors: %s, %v", strings.Join(arg, " "), out, err))
return out
}

View File

@ -77,7 +77,7 @@ func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interfac
str := inspectFieldJSON(c, name, field)
err := json.Unmarshal([]byte(str), output)
if c != nil {
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to unmarshal: %v", err))
assert.Assert(c, err == nil, check.Commentf("failed to unmarshal: %v", err))
}
}
@ -201,7 +201,7 @@ func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result {
// Fail the test when error occurs.
func writeFile(dst, content string, c *testing.T) {
// Create subdirectories if necessary
assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700), checker.IsNil)
assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700) == nil)
f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700)
assert.NilError(c, err)
defer f.Close()
@ -263,7 +263,7 @@ func daemonTime(c *testing.T) time.Time {
assert.NilError(c, err)
dt, err := time.Parse(time.RFC3339Nano, info.SystemTime)
assert.Assert(c, err, checker.IsNil, check.Commentf("invalid time format in GET /info response"))
assert.Assert(c, err == nil, check.Commentf("invalid time format in GET /info response"))
return dt
}
@ -408,7 +408,7 @@ func waitForGoroutines(expected int) error {
// getErrorMessage returns the error message from an error API response
func getErrorMessage(c *testing.T, body []byte) string {
var resp types.ErrorResponse
assert.Assert(c, json.Unmarshal(body, &resp), checker.IsNil)
assert.Assert(c, json.Unmarshal(body, &resp) == nil)
return strings.TrimSpace(resp.Message)
}

View File

@ -15,12 +15,12 @@ var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestNewEntry(c *testing.T) {
entry, err := NewEntry("127.0.0.1:2375")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
assert.Equal(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), true)
assert.Equal(c, entry.String(), "127.0.0.1:2375")
entry, err = NewEntry("[2001:db8:0:f101::2]:2375")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
assert.Equal(c, entry.Equals(&Entry{Host: "2001:db8:0:f101::2", Port: "2375"}), true)
assert.Equal(c, entry.String(), "[2001:db8:0:f101::2]:2375")
@ -53,10 +53,10 @@ func (s *DiscoverySuite) TestParse(c *testing.T) {
func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
entries, err := CreateEntries(nil)
assert.DeepEqual(c, entries, Entries{})
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
entries, err = CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", "[2001:db8:0:f101::2]:2375", ""})
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
expected := Entries{
&Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.2", Port: "2375"},
@ -70,7 +70,7 @@ func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
func (s *DiscoverySuite) TestContainsEntry(c *testing.T) {
entries, err := CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""})
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
assert.Equal(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), true)
assert.Equal(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), false)
}

View File

@ -25,7 +25,7 @@ func (s *DiscoverySuite) TestInitialize(c *testing.T) {
func (s *DiscoverySuite) TestNew(c *testing.T) {
d, err := discovery.New("file:///path/to/file", 0, 0, nil)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
assert.Equal(c, d.(*Discovery).path, "/path/to/file")
}
@ -75,9 +75,9 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) {
// Create a temporary file and remove it.
tmp, err := ioutil.TempFile(os.TempDir(), "discovery-file-test")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, tmp.Close(), checker.IsNil)
assert.Assert(c, os.Remove(tmp.Name()), checker.IsNil)
assert.Assert(c, err == nil)
assert.Assert(c, tmp.Close() == nil)
assert.Assert(c, os.Remove(tmp.Name()) == nil)
// Set up file discovery.
d := &Discovery{}
@ -94,21 +94,21 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) {
}()
// Write the file and make sure we get the expected value back.
assert.Assert(c, ioutil.WriteFile(tmp.Name(), []byte(data), 0600), checker.IsNil)
assert.Assert(c, ioutil.WriteFile(tmp.Name(), []byte(data), 0600) == nil)
assert.DeepEqual(c, <-ch, expected)
// Add a new entry and look it up.
expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"})
f, err := os.OpenFile(tmp.Name(), os.O_APPEND|os.O_WRONLY, 0600)
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
assert.Assert(c, f, checker.NotNil)
_, err = f.WriteString("\n3.3.3.3:3333\n")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
f.Close()
assert.DeepEqual(c, <-ch, expected)
// Stop and make sure it closes all channels.
close(stopCh)
assert.Assert(c, <-ch, checker.IsNil)
assert.Assert(c, <-errCh, checker.IsNil)
assert.Assert(c, <-ch == nil)
assert.Assert(c, <-errCh == nil)
}

View File

@ -181,12 +181,12 @@ BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I=
-----END RSA PRIVATE KEY-----
`
certFile, err := ioutil.TempFile("", "cert")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
defer os.Remove(certFile.Name())
certFile.Write([]byte(cert))
certFile.Close()
keyFile, err := ioutil.TempFile("", "key")
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
defer os.Remove(keyFile.Name())
keyFile.Write([]byte(key))
keyFile.Close()
@ -198,7 +198,7 @@ BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I=
"kv.certfile": certFile.Name(),
"kv.keyfile": keyFile.Name(),
})
assert.Assert(c, err, checker.IsNil)
assert.Assert(c, err == nil)
s := d.store.(*Mock)
assert.Assert(c, s.Options.TLS, checker.NotNil)
assert.Assert(c, s.Options.TLS.RootCAs, checker.NotNil)
@ -253,8 +253,8 @@ func (ds *DiscoverySuite) TestWatch(c *testing.T) {
// Stop and make sure it closes all channels.
close(stopCh)
assert.Assert(c, <-ch, checker.IsNil)
assert.Assert(c, <-errCh, checker.IsNil)
assert.Assert(c, <-ch == nil)
assert.Assert(c, <-errCh == nil)
}
// FakeStore implements store.Store methods. It mocks all store

View File

@ -30,7 +30,7 @@ func (s *discoverySuite) TestWatch(c *testing.T) {
&discovery.Entry{Host: "1.1.1.1", Port: "1111"},
}
assert.Assert(c, d.Register("1.1.1.1:1111"), checker.IsNil)
assert.Assert(c, d.Register("1.1.1.1:1111") == nil)
assert.DeepEqual(c, <-ch, expected)
expected = discovery.Entries{
@ -38,11 +38,11 @@ func (s *discoverySuite) TestWatch(c *testing.T) {
&discovery.Entry{Host: "2.2.2.2", Port: "2222"},
}
assert.Assert(c, d.Register("2.2.2.2:2222"), checker.IsNil)
assert.Assert(c, d.Register("2.2.2.2:2222") == nil)
assert.DeepEqual(c, <-ch, expected)
// Stop and make sure it closes all channels.
close(stopCh)
assert.Assert(c, <-ch, checker.IsNil)
assert.Assert(c, <-errCh, checker.IsNil)
assert.Assert(c, <-ch == nil)
assert.Assert(c, <-errCh == nil)
}