mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Use checkers on Integration test when possible
Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
@@ -3,20 +3,17 @@ package main
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox", "top")
|
||||
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
out, _ = dockerCmd(c, "top", cleanedContainerID, "-o", "pid")
|
||||
if !strings.Contains(out, "PID") {
|
||||
c.Fatalf("did not see PID after top -o pid: %s", out)
|
||||
}
|
||||
|
||||
c.Assert(out, checker.Contains, "PID", check.Commentf("did not see PID after top -o pid: %s", out))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
|
||||
@@ -26,16 +23,10 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
|
||||
|
||||
out1, _ := dockerCmd(c, "top", cleanedContainerID)
|
||||
out2, _ := dockerCmd(c, "top", cleanedContainerID)
|
||||
out, _ = dockerCmd(c, "kill", cleanedContainerID)
|
||||
|
||||
if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") {
|
||||
c.Fatal("top should've listed `top` in the process list, but failed twice")
|
||||
} else if !strings.Contains(out1, "top") {
|
||||
c.Fatal("top should've listed `top` in the process list, but failed the first time")
|
||||
} else if !strings.Contains(out2, "top") {
|
||||
c.Fatal("top should've listed `top` in the process list, but failed the second itime")
|
||||
}
|
||||
dockerCmd(c, "kill", cleanedContainerID)
|
||||
|
||||
c.Assert(out1, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the first time"))
|
||||
c.Assert(out2, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the second time"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestTopPrivileged(c *check.C) {
|
||||
@@ -45,14 +36,8 @@ func (s *DockerSuite) TestTopPrivileged(c *check.C) {
|
||||
|
||||
out1, _ := dockerCmd(c, "top", cleanedContainerID)
|
||||
out2, _ := dockerCmd(c, "top", cleanedContainerID)
|
||||
out, _ = dockerCmd(c, "kill", cleanedContainerID)
|
||||
|
||||
if !strings.Contains(out1, "top") && !strings.Contains(out2, "top") {
|
||||
c.Fatal("top should've listed `top` in the process list, but failed twice")
|
||||
} else if !strings.Contains(out1, "top") {
|
||||
c.Fatal("top should've listed `top` in the process list, but failed the first time")
|
||||
} else if !strings.Contains(out2, "top") {
|
||||
c.Fatal("top should've listed `top` in the process list, but failed the second itime")
|
||||
}
|
||||
dockerCmd(c, "kill", cleanedContainerID)
|
||||
|
||||
c.Assert(out1, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the first time"))
|
||||
c.Assert(out2, checker.Contains, "top", check.Commentf("top should've listed `top` in the process list, but failed the second time"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user