1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03:00

rm-gocheck: NotNil

sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.NotNil\b#assert.Assert(c, \1 != nil#g' \
-- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_by_digest_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_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_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/nodes/nodes_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 2743e2d8bc
commit 64a161aa3e
22 changed files with 67 additions and 67 deletions

View File

@ -5395,14 +5395,14 @@ func (s *DockerSuite) TestBuildWithFailure(c *testing.T) {
// First test case can only detect `nobody` in runtime so all steps will show up // First test case can only detect `nobody` in runtime so all steps will show up
dockerfile := "FROM busybox\nRUN nobody" dockerfile := "FROM busybox\nRUN nobody"
result := buildImage(name, build.WithDockerfile(dockerfile)) result := buildImage(name, build.WithDockerfile(dockerfile))
assert.Assert(c, result.Error, checker.NotNil) assert.Assert(c, result.Error != nil)
assert.Assert(c, result.Stdout(), checker.Contains, "Step 1/2 : FROM busybox") assert.Assert(c, result.Stdout(), checker.Contains, "Step 1/2 : FROM busybox")
assert.Assert(c, result.Stdout(), checker.Contains, "Step 2/2 : RUN nobody") assert.Assert(c, result.Stdout(), checker.Contains, "Step 2/2 : RUN nobody")
// Second test case `FFOM` should have been detected before build runs so no steps // Second test case `FFOM` should have been detected before build runs so no steps
dockerfile = "FFOM nobody\nRUN nobody" dockerfile = "FFOM nobody\nRUN nobody"
result = buildImage(name, build.WithDockerfile(dockerfile)) result = buildImage(name, build.WithDockerfile(dockerfile))
assert.Assert(c, result.Error, checker.NotNil) assert.Assert(c, result.Error != nil)
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "Step 1/2 : FROM busybox") assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "Step 1/2 : FROM busybox")
assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "Step 2/2 : RUN nobody") assert.Assert(c, result.Stdout(), checker.Not(checker.Contains), "Step 2/2 : RUN nobody")
} }

View File

@ -115,7 +115,7 @@ func testPullByDigestNoFallback(c *testing.T) {
// pull from the registry using the <name>@<digest> reference // pull from the registry using the <name>@<digest> reference
imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName) imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName)
out, _, err := dockerCmdWithError("pull", imageReference) out, _, err := dockerCmdWithError("pull", imageReference)
assert.Assert(c, err, checker.NotNil, check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image")) assert.Assert(c, err != nil, check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
assert.Assert(c, out, checker.Contains, fmt.Sprintf("manifest for %s not found", imageReference), check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image")) assert.Assert(c, out, checker.Contains, fmt.Sprintf("manifest for %s not found", imageReference), check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
} }

View File

@ -100,7 +100,7 @@ func (s *DockerSuite) TestCreateHostConfig(c *testing.T) {
assert.Equal(c, len(containers), 1) assert.Equal(c, len(containers), 1)
cont := containers[0] cont := containers[0]
assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none")) assert.Assert(c, cont.HostConfig != nil, check.Commentf("Expected HostConfig, got none"))
assert.Assert(c, cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false")) assert.Assert(c, cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false"))
} }
@ -122,7 +122,7 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) {
cont := containers[0] cont := containers[0]
assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none")) assert.Assert(c, cont.HostConfig != nil, check.Commentf("Expected HostConfig, got none"))
assert.Equal(c, len(cont.HostConfig.PortBindings), 4, check.Commentf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings))) assert.Equal(c, len(cont.HostConfig.PortBindings), 4, check.Commentf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings)))
for k, v := range cont.HostConfig.PortBindings { for k, v := range cont.HostConfig.PortBindings {
@ -151,7 +151,7 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) {
assert.Equal(c, len(containers), 1) assert.Equal(c, len(containers), 1)
cont := containers[0] cont := containers[0]
assert.Assert(c, cont.HostConfig, checker.NotNil, check.Commentf("Expected HostConfig, got none")) assert.Assert(c, cont.HostConfig != nil, check.Commentf("Expected HostConfig, got none"))
assert.Equal(c, len(cont.HostConfig.PortBindings), 65535) assert.Equal(c, len(cont.HostConfig.PortBindings), 65535)
for k, v := range cont.HostConfig.PortBindings { for k, v := range cont.HostConfig.PortBindings {

View File

@ -216,7 +216,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *testing.T) {
if newBasesizeBytes < oldBasesizeBytes { if newBasesizeBytes < oldBasesizeBytes {
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
assert.Assert(c, err, checker.NotNil, check.Commentf("daemon should not have started as new base device size is less than existing base device size: %v", err)) assert.Assert(c, err != nil, check.Commentf("daemon should not have started as new base device size is less than existing base device size: %v", err))
// 'err != nil' is expected behaviour, no new daemon started, // 'err != nil' is expected behaviour, no new daemon started,
// so no need to stop daemon. // so no need to stop daemon.
if err != nil { if err != nil {
@ -434,7 +434,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {
out = strings.Trim(out, " \r\n'") out = strings.Trim(out, " \r\n'")
ip := net.ParseIP(out) ip := net.ParseIP(out)
assert.Assert(c, ip, checker.NotNil, check.Commentf("Container should have a global IPv6 address")) assert.Assert(c, ip != nil, check.Commentf("Container should have a global IPv6 address"))
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.IPv6Gateway}}", "ipv6test") out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.IPv6Gateway}}", "ipv6test")
assert.NilError(c, err, out) assert.NilError(c, err, out)
@ -477,7 +477,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *testing.T) {
} }
func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *testing.T) { func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *testing.T) {
assert.Assert(c, s.d.StartWithError("--log-level=bogus"), checker.NotNil, check.Commentf("Daemon shouldn't start with wrong log level")) assert.Assert(c, s.d.StartWithError("--log-level=bogus") != nil, check.Commentf("Daemon shouldn't start with wrong log level"))
} }
func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *testing.T) { func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *testing.T) {
@ -844,7 +844,7 @@ func (s *DockerDaemonSuite) TestDaemonIP(c *testing.T) {
defer d.Restart(c) defer d.Restart(c)
out, err := d.Cmd("run", "-d", "-p", "8000:8000", "busybox", "top") out, err := d.Cmd("run", "-d", "-p", "8000:8000", "busybox", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("Running a container must fail with an invalid --ip option")) assert.Assert(c, err != nil, check.Commentf("Running a container must fail with an invalid --ip option"))
assert.Equal(c, strings.Contains(out, "Error starting userland proxy"), true) assert.Equal(c, strings.Contains(out, "Error starting userland proxy"), true)
ifName := "dummy" ifName := "dummy"
@ -1136,7 +1136,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *testing.T) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
out, err = s.d.Cmd("logs", "test") out, err = s.d.Cmd("logs", "test")
assert.Assert(c, err, checker.NotNil, check.Commentf("Logs should fail with 'none' driver")) assert.Assert(c, err != nil, check.Commentf("Logs should fail with 'none' driver"))
expected := `configured logging driver does not support reading` expected := `configured logging driver does not support reading`
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
@ -1630,7 +1630,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *testing.T) {
s.d.Restart(c) s.d.Restart(c)
out, err = s.d.Cmd("volume", "rm", "test") out, err = s.d.Cmd("volume", "rm", "test")
assert.Assert(c, err, checker.NotNil, check.Commentf("should not be able to remove in use volume after daemon restart")) assert.Assert(c, err != nil, check.Commentf("should not be able to remove in use volume after daemon restart"))
assert.Assert(c, out, checker.Contains, "in use") assert.Assert(c, out, checker.Contains, "in use")
} }
@ -1648,7 +1648,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *testing.T) {
// FIXME(vdemeester) should be a unit test // FIXME(vdemeester) should be a unit test
func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *testing.T) { func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *testing.T) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
assert.Assert(c, d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), checker.NotNil) assert.Assert(c, d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42") != nil)
expected := "syslog-address should be in form proto://address" expected := "syslog-address should be in form proto://address"
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success) icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
} }
@ -1656,7 +1656,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *testing.T) {
// FIXME(vdemeester) should be a unit test // FIXME(vdemeester) should be a unit test
func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *testing.T) { func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *testing.T) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
assert.Assert(c, d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), checker.NotNil) assert.Assert(c, d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c") != nil)
expected := "invalid fluentd-address corrupted:c: " expected := "invalid fluentd-address corrupted:c: "
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success) icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
} }
@ -1725,7 +1725,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithDefaultTLSHost(c *testing.T) {
assert.NilError(c, err) assert.NilError(c, err)
conn.Close() conn.Close()
assert.Assert(c, certRequestInfo, checker.NotNil) assert.Assert(c, certRequestInfo != nil)
assert.Equal(c, len(certRequestInfo.AcceptableCAs), 1) assert.Equal(c, len(certRequestInfo.AcceptableCAs), 1)
assert.DeepEqual(c, certRequestInfo.AcceptableCAs[0], rootCert.RawSubject) assert.DeepEqual(c, certRequestInfo.AcceptableCAs[0], rootCert.RawSubject)
} }
@ -1779,7 +1779,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) {
// pull a repository large enough to overfill the mounted filesystem // pull a repository large enough to overfill the mounted filesystem
pullOut, err := s.d.Cmd("pull", "debian:stretch") pullOut, err := s.d.Cmd("pull", "debian:stretch")
assert.Assert(c, err, checker.NotNil, check.Commentf("%s", pullOut)) assert.Assert(c, err != nil, check.Commentf("%s", pullOut))
assert.Assert(c, pullOut, checker.Contains, "no space left on device") assert.Assert(c, pullOut, checker.Contains, "no space left on device")
} }
@ -2546,7 +2546,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *testing.T) {
// Check that we can't override the default runtime // Check that we can't override the default runtime
s.d.Stop(c) s.d.Stop(c)
assert.Assert(c, s.d.StartWithError("--add-runtime", "runc=my-runc"), checker.NotNil) assert.Assert(c, s.d.StartWithError("--add-runtime", "runc=my-runc") != nil)
content, err := s.d.ReadLogFile() content, err := s.d.ReadLogFile()
assert.NilError(c, err) assert.NilError(c, err)

View File

@ -287,7 +287,7 @@ func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing
dockerCmd(c, "volume", "create", "test") dockerCmd(c, "volume", "create", "test")
out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName) out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName)
assert.Assert(c, err, checker.NotNil, check.Commentf("volume create exception name already in use with another driver")) assert.Assert(c, err != nil, check.Commentf("volume create exception name already in use with another driver"))
assert.Assert(c, out, checker.Contains, "must be unique") assert.Assert(c, out, checker.Contains, "must be unique")
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test") out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test")
@ -585,7 +585,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *t
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, len(vs), 1) assert.Equal(c, len(vs), 1)
assert.Equal(c, vs[0].Driver, driverName) assert.Equal(c, vs[0].Driver, driverName)
assert.Assert(c, vs[0].Options, checker.NotNil) assert.Assert(c, vs[0].Options != nil)
assert.Equal(c, vs[0].Options["foo"], "bar") assert.Equal(c, vs[0].Options["foo"], "bar")
assert.Equal(c, vs[0].Driver, driverName) assert.Equal(c, vs[0].Driver, driverName)

View File

@ -61,7 +61,7 @@ func (s *DockerSuite) TestHistoryExistentImage(c *testing.T) {
func (s *DockerSuite) TestHistoryNonExistentImage(c *testing.T) { func (s *DockerSuite) TestHistoryNonExistentImage(c *testing.T) {
_, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage") _, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage")
assert.Assert(c, err, checker.NotNil, check.Commentf("history on a non-existent image should fail.")) assert.Assert(c, err != nil, check.Commentf("history on a non-existent image should fail."))
} }
func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) { func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) {

View File

@ -36,7 +36,7 @@ func (s *DockerSuite) TestImportDisplay(c *testing.T) {
func (s *DockerSuite) TestImportBadURL(c *testing.T) { func (s *DockerSuite) TestImportBadURL(c *testing.T) {
out, _, err := dockerCmdWithError("import", "http://nourl/bad") out, _, err := dockerCmdWithError("import", "http://nourl/bad")
assert.Assert(c, err, checker.NotNil, check.Commentf("import was supposed to fail but didn't")) assert.Assert(c, err != nil, check.Commentf("import was supposed to fail but didn't"))
// Depending on your system you can get either of these errors // Depending on your system you can get either of these errors
if !strings.Contains(out, "dial tcp") && if !strings.Contains(out, "dial tcp") &&
!strings.Contains(out, "ApplyLayer exit status 1 stdout: stderr: archive/tar: invalid tar header") && !strings.Contains(out, "ApplyLayer exit status 1 stdout: stderr: archive/tar: invalid tar header") &&
@ -122,7 +122,7 @@ func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) {
func (s *DockerSuite) TestImportFileNonExistentFile(c *testing.T) { func (s *DockerSuite) TestImportFileNonExistentFile(c *testing.T) {
_, _, err := dockerCmdWithError("import", "example.com/myImage.tar") _, _, err := dockerCmdWithError("import", "example.com/myImage.tar")
assert.Assert(c, err, checker.NotNil, check.Commentf("import non-existing file must failed")) assert.Assert(c, err != nil, check.Commentf("import non-existing file must failed"))
} }
func (s *DockerSuite) TestImportWithQuotedChanges(c *testing.T) { func (s *DockerSuite) TestImportWithQuotedChanges(c *testing.T) {

View File

@ -119,7 +119,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) {
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox") out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox")
assert.Assert(c, err, checker.NotNil, check.Commentf("%d", exitCode)) assert.Assert(c, err != nil, check.Commentf("%d", exitCode))
assert.Equal(c, exitCode, 1, check.Commentf("%s", err)) assert.Equal(c, exitCode, 1, check.Commentf("%s", err))
assert.Assert(c, out, checker.Contains, "not a valid value for --type") assert.Assert(c, out, checker.Contains, "not a valid value for --type")
} }

View File

@ -27,7 +27,7 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *testing.T) {
out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true") out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true")
// an invalid container target should produce an error // an invalid container target should produce an error
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
// an invalid container target should produce an error // an invalid container target should produce an error
// note: convert the output to lowercase first as the error string // note: convert the output to lowercase first as the error string
// capitalization was changed after API version 1.32 // capitalization was changed after API version 1.32
@ -169,7 +169,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
getIP := func(hosts []byte, hostname string) string { getIP := func(hosts []byte, hostname string) string {
re := regexp.MustCompile(fmt.Sprintf(`(\S*)\t%s`, regexp.QuoteMeta(hostname))) re := regexp.MustCompile(fmt.Sprintf(`(\S*)\t%s`, regexp.QuoteMeta(hostname)))
matches := re.FindSubmatch(hosts) matches := re.FindSubmatch(hosts)
assert.Assert(c, matches, checker.NotNil, check.Commentf("Hostname %s have no matches in hosts", hostname)) assert.Assert(c, matches != nil, check.Commentf("Hostname %s have no matches in hosts", hostname))
return string(matches[1]) return string(matches[1])
} }
ip := getIP(content, "one") ip := getIP(content, "one")
@ -220,7 +220,7 @@ func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) {
out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true") out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true")
// Running container linking to a container with --net host should have failed // Running container linking to a container with --net host should have failed
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
// Running container linking to a container with --net host should have failed // Running container linking to a container with --net host should have failed
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
} }

View File

@ -19,7 +19,7 @@ const stringCheckPS = "PID USER"
// stop the tests. // stop the tests.
func dockerCmdWithFail(c *testing.T, args ...string) (string, int) { func dockerCmdWithFail(c *testing.T, args ...string) (string, int) {
out, status, err := dockerCmdWithError(args...) out, status, err := dockerCmdWithError(args...)
assert.Assert(c, err, checker.NotNil, check.Commentf("%v", out)) assert.Assert(c, err != nil, check.Commentf("%v", out))
return out, status return out, status
} }

View File

@ -64,7 +64,7 @@ func (s *DockerNetworkSuite) TearDownTest(c *testing.T) {
func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) { func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) {
mux := http.NewServeMux() mux := http.NewServeMux()
s.server = httptest.NewServer(mux) s.server = httptest.NewServer(mux)
assert.Assert(c, s.server, checker.NotNil, check.Commentf("Failed to start an HTTP Server")) assert.Assert(c, s.server != nil, check.Commentf("Failed to start an HTTP Server"))
setupRemoteNetworkDrivers(c, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver) setupRemoteNetworkDrivers(c, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver)
} }
@ -416,7 +416,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) {
// contains active container, its deletion should fail. // contains active container, its deletion should fail.
out, _, err := dockerCmdWithError("network", "rm", "testDelMulti0", "testDelMulti1", "testDelMulti2") out, _, err := dockerCmdWithError("network", "rm", "testDelMulti0", "testDelMulti1", "testDelMulti2")
// err should not be nil due to deleting testDelMulti2 failed. // err should not be nil due to deleting testDelMulti2 failed.
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
// testDelMulti2 should fail due to network has active endpoints // testDelMulti2 should fail due to network has active endpoints
assert.Assert(c, out, checker.Contains, "has active endpoints") assert.Assert(c, out, checker.Contains, "has active endpoints")
assertNwNotAvailable(c, "testDelMulti0") assertNwNotAvailable(c, "testDelMulti0")
@ -765,7 +765,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *testing.T) {
dockerCmd(c, "network", "create", "-d", dummyNetworkDriver, "-o", "opt1=drv1", "-o", "opt2=drv2", "testopt") dockerCmd(c, "network", "create", "-d", dummyNetworkDriver, "-o", "opt1=drv1", "-o", "opt2=drv2", "testopt")
assertNwIsAvailable(c, "testopt") assertNwIsAvailable(c, "testopt")
gopts := remoteDriverNetworkRequest.Options[netlabel.GenericData] gopts := remoteDriverNetworkRequest.Options[netlabel.GenericData]
assert.Assert(c, gopts, checker.NotNil) assert.Assert(c, gopts != nil)
opts, ok := gopts.(map[string]interface{}) opts, ok := gopts.(map[string]interface{})
assert.Equal(c, ok, true) assert.Equal(c, ok, true)
assert.Equal(c, opts["opt1"], "drv1") assert.Equal(c, opts["opt1"], "drv1")
@ -1149,7 +1149,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", "container1", "--net=host", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container1", "--net=host", "busybox", "top")
assert.Assert(c, waitRun("container1") == nil) assert.Assert(c, waitRun("container1") == nil)
out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1") out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1")
assert.Assert(c, err, checker.NotNil, check.Commentf("Should err out disconnect from host")) assert.Assert(c, err != nil, check.Commentf("Should err out disconnect from host"))
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
} }
@ -1317,7 +1317,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
// Still it should fail to connect to the default network with a specified IP (whatever ip) // Still it should fail to connect to the default network with a specified IP (whatever ip)
out, _, err := dockerCmdWithError("network", "connect", "--ip", "172.21.55.44", "bridge", "c0") out, _, err := dockerCmdWithError("network", "connect", "--ip", "172.21.55.44", "bridge", "c0")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
} }
@ -1356,11 +1356,11 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T
assertNwIsAvailable(c, "n0") assertNwIsAvailable(c, "n0")
out, _, err := dockerCmdWithError("run", "-d", "--ip", "172.28.99.88", "--net", "n0", "busybox", "top") out, _, err := dockerCmdWithError("run", "-d", "--ip", "172.28.99.88", "--net", "n0", "busybox", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())
out, _, err = dockerCmdWithError("run", "-d", "--ip6", "2001:db8:1234::9988", "--net", "n0", "busybox", "top") out, _, err = dockerCmdWithError("run", "-d", "--ip6", "2001:db8:1234::9988", "--net", "n0", "busybox", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())
dockerCmd(c, "network", "rm", "n0") dockerCmd(c, "network", "rm", "n0")
@ -1369,7 +1369,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T
func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) { func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) {
out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top") out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
} }
@ -1560,12 +1560,12 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T)
// verify the alias option is rejected when running on predefined network // verify the alias option is rejected when running on predefined network
out, _, err := dockerCmdWithError("run", "--rm", "--name=any", "--net-alias=any", "busybox:glibc", "top") out, _, err := dockerCmdWithError("run", "--rm", "--name=any", "--net-alias=any", "busybox:glibc", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
// verify the alias option is rejected when connecting to predefined network // verify the alias option is rejected when connecting to predefined network
out, _, err = dockerCmdWithError("network", "connect", "--alias=any", "bridge", "first") out, _, err = dockerCmdWithError("network", "connect", "--alias=any", "bridge", "first")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
} }

View File

@ -105,7 +105,7 @@ func (s *DockerSuite) TestPortList(c *testing.T) {
"-p", "9090-9092:80", "-p", "9090-9092:80",
"busybox", "top") "busybox", "top")
// Exhausted port range did not return an error // Exhausted port range did not return an error
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
dockerCmd(c, "rm", "-f", IDs[i]) dockerCmd(c, "rm", "-f", IDs[i])
@ -121,7 +121,7 @@ func (s *DockerSuite) TestPortList(c *testing.T) {
"-p", invalidRange, "-p", invalidRange,
"busybox", "top") "busybox", "top")
// Port range should have returned an error // Port range should have returned an error
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
} }
// test host range:container range spec. // test host range:container range spec.
@ -302,7 +302,7 @@ func (s *DockerSuite) TestPortHostBinding(c *testing.T) {
out, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "9876") out, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "9876")
// Port is still bound after the Container is removed // Port is still bound after the Container is removed
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
} }
func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) { func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) {
@ -324,7 +324,7 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) {
out, _, err = dockerCmdWithError("run", "--net=host", "busybox", out, _, err = dockerCmdWithError("run", "--net=host", "busybox",
"nc", "localhost", strings.TrimSpace(exposedPort)) "nc", "localhost", strings.TrimSpace(exposedPort))
// Port is still bound after the Container is removed // Port is still bound after the Container is removed
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
} }
func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) { func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
@ -338,7 +338,7 @@ func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
assert.Assert(c, waitRun("c1") == nil) assert.Assert(c, waitRun("c1") == nil)
_, _, err := dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080") _, _, 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")) assert.Assert(c, err != nil, check.Commentf("Port mapping on internal network is expected to fail"))
// Connect container to another normal bridge network // Connect container to another normal bridge network
dockerCmd(c, "network", "create", "-d", "bridge", "foo-net") dockerCmd(c, "network", "create", "-d", "bridge", "foo-net")
dockerCmd(c, "network", "connect", "foo-net", "c1") dockerCmd(c, "network", "connect", "foo-net", "c1")

View File

@ -443,11 +443,11 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) {
secondZero, _ := dockerCmd(c, "run", "-d", "busybox", "true") secondZero, _ := dockerCmd(c, "run", "-d", "busybox", "true")
out, _, err := dockerCmdWithError("run", "--name", "nonzero1", "busybox", "false") out, _, err := dockerCmdWithError("run", "--name", "nonzero1", "busybox", "false")
assert.Assert(c, err, checker.NotNil, check.Commentf("Should fail. out: %s", out)) assert.Assert(c, err != nil, check.Commentf("Should fail. out: %s", out))
firstNonZero := getIDByName(c, "nonzero1") firstNonZero := getIDByName(c, "nonzero1")
out, _, err = dockerCmdWithError("run", "--name", "nonzero2", "busybox", "false") out, _, err = dockerCmdWithError("run", "--name", "nonzero2", "busybox", "false")
assert.Assert(c, err, checker.NotNil, check.Commentf("Should fail. out: %s", out)) assert.Assert(c, err != nil, check.Commentf("Should fail. out: %s", out))
secondNonZero := getIDByName(c, "nonzero2") secondNonZero := getIDByName(c, "nonzero2")
// filter containers by exited=0 // filter containers by exited=0

View File

@ -2294,7 +2294,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) {
func (s *DockerSuite) TestRunExposePort(c *testing.T) { func (s *DockerSuite) TestRunExposePort(c *testing.T) {
out, _, err := dockerCmdWithError("run", "--expose", "80000", "busybox") out, _, err := dockerCmdWithError("run", "--expose", "80000", "busybox")
assert.Assert(c, err, checker.NotNil, check.Commentf("--expose with an invalid port should error out")) assert.Assert(c, err != nil, check.Commentf("--expose with an invalid port should error out"))
assert.Assert(c, out, checker.Contains, "invalid range format for --expose") assert.Assert(c, out, checker.Contains, "invalid range format for --expose")
} }
@ -3210,10 +3210,10 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "unique_name" name := "unique_name"
_, _, err := dockerCmdWithError("run", "--name", name, "--link", "nothing:nothing", "busybox") _, _, err := dockerCmdWithError("run", "--name", name, "--link", "nothing:nothing", "busybox")
assert.Assert(c, err, checker.NotNil, check.Commentf("Expected docker run to fail!")) assert.Assert(c, err != nil, check.Commentf("Expected docker run to fail!"))
containerID, err := inspectFieldWithError(name, "Id") containerID, err := inspectFieldWithError(name, "Id")
assert.Assert(c, err, checker.NotNil, check.Commentf("Expected not to have this container: %s!", containerID)) assert.Assert(c, err != nil, check.Commentf("Expected not to have this container: %s!", containerID))
assert.Equal(c, containerID, "", check.Commentf("Expected not to have this container: %s!", containerID)) assert.Equal(c, containerID, "", check.Commentf("Expected not to have this container: %s!", containerID))
} }
@ -3950,7 +3950,7 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
// We will need the following `inspect` to diagnose the issue if test fails (#21247) // We will need the following `inspect` to diagnose the issue if test fails (#21247)
out1, err1 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "test") out1, err1 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "test")
out2, err2 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "fail") out2, err2 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "fail")
assert.Assert(c, err, checker.NotNil, check.Commentf("Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2)) assert.Assert(c, err != nil, check.Commentf("Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2))
// check for windows error as well // check for windows error as well
// TODO Windows Post TP5. Fix the error message string // TODO Windows Post TP5. Fix the error message string
assert.Assert(c, strings.Contains(string(out), "port is already allocated") || assert.Assert(c, strings.Contains(string(out), "port is already allocated") ||
@ -4162,7 +4162,7 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) {
} }
for _, attempt := range attempts { for _, attempt := range attempts {
_, _, err := dockerCmdWithError("run", "--security-opt=credentialspec="+attempt.value, "busybox", "true") _, _, err := dockerCmdWithError("run", "--security-opt=credentialspec="+attempt.value, "busybox", "true")
assert.Assert(c, err, checker.NotNil, check.Commentf("%s expected non-nil err", attempt.value)) assert.Assert(c, err != nil, check.Commentf("%s expected non-nil err", attempt.value))
assert.Assert(c, err.Error(), checker.Contains, attempt.expectedError, check.Commentf("%s expected %s got %s", attempt.value, attempt.expectedError, err)) assert.Assert(c, err.Error(), checker.Contains, attempt.expectedError, check.Commentf("%s expected %s got %s", attempt.value, attempt.expectedError, err))
} }
} }
@ -4501,7 +4501,7 @@ func (s *DockerSuite) TestRunMount(c *testing.T) {
assert.Assert(c, testCase.fn(cName) == nil, check.Commentf("got error while executing test for %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) dockerCmd(c, "rm", "-f", cName)
} else { } else {
assert.Assert(c, err, checker.NotNil, check.Commentf("got nil while creating a container with %v (%s)", opts, cName)) assert.Assert(c, err != nil, check.Commentf("got nil while creating a container with %v (%s)", opts, cName))
} }
} }
} }

View File

@ -47,7 +47,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
assert.Equal(c, mountConfig[0].Source, "foo") assert.Equal(c, mountConfig[0].Source, "foo")
assert.Equal(c, mountConfig[0].Target, "/foo") assert.Equal(c, mountConfig[0].Target, "/foo")
assert.Equal(c, mountConfig[0].Type, mount.TypeVolume) assert.Equal(c, mountConfig[0].Type, mount.TypeVolume)
assert.Assert(c, mountConfig[0].VolumeOptions, checker.NotNil) assert.Assert(c, mountConfig[0].VolumeOptions != nil)
assert.Assert(c, mountConfig[0].VolumeOptions.NoCopy, checker.True) assert.Assert(c, mountConfig[0].VolumeOptions.NoCopy, checker.True)
// check container mounts actual // check container mounts actual
@ -390,7 +390,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
assert.Equal(c, mountConfig[0].Source, "") assert.Equal(c, mountConfig[0].Source, "")
assert.Equal(c, mountConfig[0].Target, "/foo") assert.Equal(c, mountConfig[0].Target, "/foo")
assert.Equal(c, mountConfig[0].Type, mount.TypeTmpfs) assert.Equal(c, mountConfig[0].Type, mount.TypeTmpfs)
assert.Assert(c, mountConfig[0].TmpfsOptions, checker.NotNil) assert.Assert(c, mountConfig[0].TmpfsOptions != nil)
assert.Equal(c, mountConfig[0].TmpfsOptions.SizeBytes, int64(1048576)) assert.Equal(c, mountConfig[0].TmpfsOptions.SizeBytes, int64(1048576))
// check container mounts actual // check container mounts actual

View File

@ -21,7 +21,7 @@ func (s *DockerSuite) TestStartAttachReturnsOnError(c *testing.T) {
// Expect this to fail because the above container is stopped, this is what we want // Expect this to fail because the above container is stopped, this is what we want
out, _, err := dockerCmdWithError("run", "--name", "test2", "--link", "test:test", "busybox") out, _, err := dockerCmdWithError("run", "--name", "test2", "--link", "test:test", "busybox")
// err shouldn't be nil because container test2 try to link to stopped container // err shouldn't be nil because container test2 try to link to stopped container
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
ch := make(chan error) ch := make(chan error)
go func() { go func() {
@ -79,7 +79,7 @@ func (s *DockerSuite) TestStartRecordError(c *testing.T) {
// Expect this to fail and records error because of ports conflict // Expect this to fail and records error because of ports conflict
out, _, err := dockerCmdWithError("run", "-d", "--name", "test2", "-p", "9999:9999", "busybox", "top") out, _, err := dockerCmdWithError("run", "-d", "--name", "test2", "-p", "9999:9999", "busybox", "top")
// err shouldn't be nil because docker run will fail // err shouldn't be nil because docker run will fail
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
stateErr = inspectField(c, "test2", "State.Error") stateErr = inspectField(c, "test2", "State.Error")
assert.Assert(c, stateErr, checker.Contains, "port is already allocated") assert.Assert(c, stateErr, checker.Contains, "port is already allocated")
@ -102,7 +102,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *testing.T) {
out, _, err := dockerCmdWithError("start", "testing") out, _, err := dockerCmdWithError("start", "testing")
// an error should have been shown that you cannot start paused container // an error should have been shown that you cannot start paused container
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
// an error should have been shown that you cannot start paused container // an error should have been shown that you cannot start paused container
assert.Assert(c, strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead") assert.Assert(c, strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead")
} }
@ -130,7 +130,7 @@ func (s *DockerSuite) TestStartMultipleContainers(c *testing.T) {
expErr := "failed to start containers: [child_first]" expErr := "failed to start containers: [child_first]"
out, _, err := dockerCmdWithError("start", "child_first", "parent", "child_second") out, _, err := dockerCmdWithError("start", "child_first", "parent", "child_second")
// err shouldn't be nil because start will fail // err shouldn't be nil because start will fail
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
// output does not correspond to what was expected // output does not correspond to what was expected
if !(strings.Contains(out, expOut) || strings.Contains(err.Error(), expErr)) { if !(strings.Contains(out, expOut) || strings.Contains(err.Error(), expErr)) {
c.Fatalf("Expected out: %v with err: %v but got out: %v with err: %v", expOut, expErr, out, err) c.Fatalf("Expected out: %v with err: %v but got out: %v with err: %v", expOut, expErr, out, err)
@ -158,7 +158,7 @@ func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) {
for _, option := range []string{"-a", "-i", "-ai"} { for _, option := range []string{"-a", "-i", "-ai"} {
out, _, err := dockerCmdWithError("start", option, "test1", "test2", "test3") out, _, err := dockerCmdWithError("start", option, "test1", "test2", "test3")
// err shouldn't be nil because start will fail // err shouldn't be nil because start will fail
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err != nil, check.Commentf("out: %s", out))
// output does not correspond to what was expected // output does not correspond to what was expected
assert.Assert(c, out, checker.Contains, "you cannot start and attach multiple containers at once") assert.Assert(c, out, checker.Contains, "you cannot start and attach multiple containers at once")
} }

View File

@ -803,7 +803,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) { func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) {
mux := http.NewServeMux() mux := http.NewServeMux()
s.server = httptest.NewServer(mux) s.server = httptest.NewServer(mux)
assert.Assert(c, s.server, checker.NotNil) // check that HTTP server has started assert.Assert(c, s.server != nil) // check that HTTP server has started
setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin) setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin)
defer func() { defer func() {
s.server.Close() s.server.Close()

View File

@ -242,7 +242,7 @@ func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) {
name := strings.TrimSpace(out) name := strings.TrimSpace(out)
out, exitCode, err := dockerCmdWithError("volume", "inspect", "--format='{{ .FooBar }}'", name) out, exitCode, err := dockerCmdWithError("volume", "inspect", "--format='{{ .FooBar }}'", name)
assert.Assert(c, err, checker.NotNil, check.Commentf("Output: %s", out)) assert.Assert(c, err != nil, check.Commentf("Output: %s", out))
assert.Equal(c, exitCode, 1, check.Commentf("Output: %s", out)) assert.Equal(c, exitCode, 1, check.Commentf("Output: %s", out))
assert.Assert(c, out, checker.Contains, "Template parsing error") assert.Assert(c, out, checker.Contains, "Template parsing error")
} }

View File

@ -25,7 +25,7 @@ func (s *DiscoverySuite) TestNewEntry(c *testing.T) {
assert.Equal(c, entry.String(), "[2001:db8:0:f101::2]:2375") assert.Equal(c, entry.String(), "[2001:db8:0:f101::2]:2375")
_, err = NewEntry("127.0.0.1") _, err = NewEntry("127.0.0.1")
assert.Assert(c, err, checker.NotNil) assert.Assert(c, err != nil)
} }
func (s *DiscoverySuite) TestParse(c *testing.T) { func (s *DiscoverySuite) TestParse(c *testing.T) {
@ -65,7 +65,7 @@ func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
assert.Equal(c, entries.Equals(expected), true) assert.Equal(c, entries.Equals(expected), true)
_, err = CreateEntries([]string{"127.0.0.1", "127.0.0.2"}) _, err = CreateEntries([]string{"127.0.0.1", "127.0.0.2"})
assert.Assert(c, err, checker.NotNil) assert.Assert(c, err != nil)
} }
func (s *DiscoverySuite) TestContainsEntry(c *testing.T) { func (s *DiscoverySuite) TestContainsEntry(c *testing.T) {

View File

@ -45,7 +45,7 @@ func (s *DiscoverySuite) TestContent(c *testing.T) {
func (s *DiscoverySuite) TestRegister(c *testing.T) { func (s *DiscoverySuite) TestRegister(c *testing.T) {
discovery := &Discovery{path: "/path/to/file"} discovery := &Discovery{path: "/path/to/file"}
assert.Assert(c, discovery.Register("0.0.0.0"), checker.NotNil) assert.Assert(c, discovery.Register("0.0.0.0") != nil)
} }
func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) { func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) {
@ -86,7 +86,7 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) {
ch, errCh := d.Watch(stopCh) ch, errCh := d.Watch(stopCh)
// Make sure it fires errors since the file doesn't exist. // Make sure it fires errors since the file doesn't exist.
assert.Assert(c, <-errCh, checker.NotNil) assert.Assert(c, <-errCh != nil)
// We have to drain the error channel otherwise Watch will get stuck. // We have to drain the error channel otherwise Watch will get stuck.
go func() { go func() {
for range errCh { for range errCh {
@ -101,7 +101,7 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) {
expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"}) 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) f, err := os.OpenFile(tmp.Name(), os.O_APPEND|os.O_WRONLY, 0600)
assert.Assert(c, err == nil) assert.Assert(c, err == nil)
assert.Assert(c, f, checker.NotNil) assert.Assert(c, f != nil)
_, err = f.WriteString("\n3.3.3.3:3333\n") _, err = f.WriteString("\n3.3.3.3:3333\n")
assert.Assert(c, err == nil) assert.Assert(c, err == nil)
f.Close() f.Close()

View File

@ -200,8 +200,8 @@ BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I=
}) })
assert.Assert(c, err == nil) assert.Assert(c, err == nil)
s := d.store.(*Mock) s := d.store.(*Mock)
assert.Assert(c, s.Options.TLS, checker.NotNil) assert.Assert(c, s.Options.TLS != nil)
assert.Assert(c, s.Options.TLS.RootCAs, checker.NotNil) assert.Assert(c, s.Options.TLS.RootCAs != nil)
assert.Equal(c, len(s.Options.TLS.Certificates), 1) assert.Equal(c, len(s.Options.TLS.Certificates), 1)
} }

View File

@ -47,5 +47,5 @@ func (s *DiscoverySuite) TestWatch(c *testing.T) {
func (s *DiscoverySuite) TestRegister(c *testing.T) { func (s *DiscoverySuite) TestRegister(c *testing.T) {
d := &Discovery{} d := &Discovery{}
assert.Assert(c, d.Register("0.0.0.0"), checker.NotNil) assert.Assert(c, d.Register("0.0.0.0") != nil)
} }