فهرست منبع

integration-cli: DockerCLITopSuite: replace dockerCmd

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 سال پیش
والد
کامیت
885eceba1d
1فایلهای تغییر یافته به همراه12 افزوده شده و 12 حذف شده
  1. 12 12
      integration-cli/docker_cli_top_test.go

+ 12 - 12
integration-cli/docker_cli_top_test.go

@@ -5,6 +5,7 @@ import (
 	"strings"
 	"strings"
 	"testing"
 	"testing"
 
 
+	"github.com/docker/docker/integration-cli/cli"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/icmd"
 	"gotest.tools/v3/icmd"
 )
 )
@@ -32,7 +33,7 @@ func (s *DockerCLITopSuite) TestTopMultipleArgs(c *testing.T) {
 	default:
 	default:
 		expected = icmd.Expected{Out: "PID"}
 		expected = icmd.Expected{Out: "PID"}
 	}
 	}
-	result := dockerCmdWithResult("top", cleanedContainerID, "-o", "pid")
+	result := cli.Docker(cli.Args("top", cleanedContainerID, "-o", "pid"))
 	result.Assert(c, expected)
 	result.Assert(c, expected)
 }
 }
 
 
@@ -40,9 +41,9 @@ func (s *DockerCLITopSuite) TestTopNonPrivileged(c *testing.T) {
 	out := runSleepingContainer(c, "-d")
 	out := runSleepingContainer(c, "-d")
 	cleanedContainerID := strings.TrimSpace(out)
 	cleanedContainerID := strings.TrimSpace(out)
 
 
-	out1, _ := dockerCmd(c, "top", cleanedContainerID)
-	out2, _ := dockerCmd(c, "top", cleanedContainerID)
-	dockerCmd(c, "kill", cleanedContainerID)
+	out1 := cli.DockerCmd(c, "top", cleanedContainerID).Combined()
+	out2 := cli.DockerCmd(c, "top", cleanedContainerID).Combined()
+	cli.DockerCmd(c, "kill", cleanedContainerID)
 
 
 	// Windows will list the name of the launched executable which in this case is busybox.exe, without the parameters.
 	// Windows will list the name of the launched executable which in this case is busybox.exe, without the parameters.
 	// Linux will display the command executed in the container
 	// Linux will display the command executed in the container
@@ -62,9 +63,8 @@ func (s *DockerCLITopSuite) TestTopNonPrivileged(c *testing.T) {
 // very different to Linux in this regard.
 // very different to Linux in this regard.
 func (s *DockerCLITopSuite) TestTopWindowsCoreProcesses(c *testing.T) {
 func (s *DockerCLITopSuite) TestTopWindowsCoreProcesses(c *testing.T) {
 	testRequires(c, DaemonIsWindows)
 	testRequires(c, DaemonIsWindows)
-	out := runSleepingContainer(c, "-d")
-	cleanedContainerID := strings.TrimSpace(out)
-	out1, _ := dockerCmd(c, "top", cleanedContainerID)
+	cID := runSleepingContainer(c, "-d")
+	out1 := cli.DockerCmd(c, "top", cID).Combined()
 	lookingFor := []string{"smss.exe", "csrss.exe", "wininit.exe", "services.exe", "lsass.exe", "CExecSvc.exe"}
 	lookingFor := []string{"smss.exe", "csrss.exe", "wininit.exe", "services.exe", "lsass.exe", "CExecSvc.exe"}
 	for i, s := range lookingFor {
 	for i, s := range lookingFor {
 		assert.Assert(c, strings.Contains(out1, s), "top should've listed `%s` in the process list, but failed. Test case %d", s, i)
 		assert.Assert(c, strings.Contains(out1, s), "top should've listed `%s` in the process list, but failed. Test case %d", s, i)
@@ -74,12 +74,12 @@ func (s *DockerCLITopSuite) TestTopWindowsCoreProcesses(c *testing.T) {
 func (s *DockerCLITopSuite) TestTopPrivileged(c *testing.T) {
 func (s *DockerCLITopSuite) TestTopPrivileged(c *testing.T) {
 	// Windows does not support --privileged
 	// Windows does not support --privileged
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
-	out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top")
-	cleanedContainerID := strings.TrimSpace(out)
+	cID := cli.DockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top").Stdout()
+	cID = strings.TrimSpace(cID)
 
 
-	out1, _ := dockerCmd(c, "top", cleanedContainerID)
-	out2, _ := dockerCmd(c, "top", cleanedContainerID)
-	dockerCmd(c, "kill", cleanedContainerID)
+	out1 := cli.DockerCmd(c, "top", cID).Combined()
+	out2 := cli.DockerCmd(c, "top", cID).Combined()
+	cli.DockerCmd(c, "kill", cID)
 
 
 	assert.Assert(c, strings.Contains(out1, "top"), "top should've listed `top` in the process list, but failed the first time")
 	assert.Assert(c, strings.Contains(out1, "top"), "top should've listed `top` in the process list, but failed the first time")
 	assert.Assert(c, strings.Contains(out2, "top"), "top should've listed `top` in the process list, but failed the second time")
 	assert.Assert(c, strings.Contains(out2, "top"), "top should've listed `top` in the process list, but failed the second time")