Skip to content

Commit

Permalink
integration-cli: dockerCmdWithFail: remove unused return
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Oct 19, 2023
1 parent 02fd848 commit 908821d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 16 additions & 17 deletions integration-cli/docker_cli_netmode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ func (s *DockerCLINetmodeSuite) OnTimeout(c *testing.T) {
}

// DockerCmdWithFail executes a docker command that is supposed to fail and returns
// the output, the exit code. If the command returns a Nil error, it will fail and
// stop the tests.
func dockerCmdWithFail(c *testing.T, args ...string) (string, int) {
out, status, err := dockerCmdWithError(args...)
// the output. If the command returns a Nil error, it will fail and stop the tests.
func dockerCmdWithFail(c *testing.T, args ...string) string {
out, _, err := dockerCmdWithError(args...)
assert.Assert(c, err != nil, "%v", out)
return out, status
return out
}

func (s *DockerCLINetmodeSuite) TestNetHostnameWithNetHost(c *testing.T) {
Expand All @@ -53,48 +52,48 @@ func (s *DockerCLINetmodeSuite) TestNetHostname(c *testing.T) {
assert.Assert(c, strings.Contains(out, stringCheckPS))
out = cli.DockerCmd(c, "run", "-h=name", "--net=none", "busybox", "ps").Stdout()
assert.Assert(c, strings.Contains(out, stringCheckPS))
out, _ = dockerCmdWithFail(c, "run", "-h=name", "--net=container:other", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "-h=name", "--net=container:other", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkHostname.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps")
assert.Assert(c, strings.Contains(out, "invalid container format container:<name|id>"))
out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
assert.Assert(c, strings.Contains(strings.ToLower(out), "not found"))
}

func (s *DockerCLINetmodeSuite) TestConflictContainerNetworkAndLinks(c *testing.T) {
testRequires(c, DaemonIsLinux)

out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps")
out := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndLinks.Error()))
}

func (s *DockerCLINetmodeSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)

out, _ := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps")
out := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
}

func (s *DockerCLINetmodeSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)

out, _ := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
out := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
}

func (s *DockerCLINetmodeSuite) TestConflictNetworkModeAndOptions(c *testing.T) {
testRequires(c, DaemonIsLinux)

out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps")
out := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkAndDNS.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--add-host=name:8.8.8.8", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=container:other", "--add-host=name:8.8.8.8", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkHosts.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=container:other", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "-P", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=container:other", "-P", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "-p", "8080", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=container:other", "-p", "8080", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--expose", "8000-9000", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "--net=container:other", "--expose", "8000-9000", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkExposePorts.Error()))
}
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ func (s *DockerCLIRunSuite) TestRunModeUTSHost(c *testing.T) {
c.Fatalf("UTS should be different without --uts=host %s == %s\n", hostUTS, out)
}

out, _ = dockerCmdWithFail(c, "run", "-h=name", "--uts=host", "busybox", "ps")
out = dockerCmdWithFail(c, "run", "-h=name", "--uts=host", "busybox", "ps")
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictUTSHostname.Error()))
}

Expand Down

0 comments on commit 908821d

Please sign in to comment.