Use checkers on Integration test when possible

Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
Hu Keping
2015-10-09 03:42:41 +08:00
committed by HuKeping
parent faa448e801
commit 72269acf29
2 changed files with 25 additions and 44 deletions

View File

@@ -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"))
}