summaryrefslogtreecommitdiff
path: root/integration-cli/docker_cli_diff_test.go
diff options
context:
space:
mode:
authorAlexander Morozov <lk4d4@docker.com>2015-04-18 09:46:47 -0700
committerAlexander Morozov <lk4d4@docker.com>2015-04-21 10:28:52 -0700
commitdc944ea7e48d11a2906e751d3e61daf08faee054 (patch)
treebc2c7f5ee0bd7cec72c7af64358554a130a0ddd6 /integration-cli/docker_cli_diff_test.go
parent6dcdf832a3dddc8de17b7f8b1fb1ddb8b20f9077 (diff)
downloaddocker-dc944ea7e48d11a2906e751d3e61daf08faee054.tar.gz
Use suite for integration-cli
It prints test name and duration for each test. Also performs deleteAllContainers after each test. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Diffstat (limited to 'integration-cli/docker_cli_diff_test.go')
-rw-r--r--integration-cli/docker_cli_diff_test.go37
1 files changed, 14 insertions, 23 deletions
diff --git a/integration-cli/docker_cli_diff_test.go b/integration-cli/docker_cli_diff_test.go
index f7f8cd7a9d..332b128ed8 100644
--- a/integration-cli/docker_cli_diff_test.go
+++ b/integration-cli/docker_cli_diff_test.go
@@ -3,16 +3,17 @@ package main
import (
"os/exec"
"strings"
- "testing"
+
+ "github.com/go-check/check"
)
// ensure that an added file shows up in docker diff
-func TestDiffFilenameShownInOutput(t *testing.T) {
+func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
containerCmd := `echo foo > /root/bar`
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
out, _, err := runCommandWithOutput(runCmd)
if err != nil {
- t.Fatalf("failed to start the container: %s, %v", out, err)
+ c.Fatalf("failed to start the container: %s, %v", out, err)
}
cleanCID := strings.TrimSpace(out)
@@ -20,7 +21,7 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
out, _, err = runCommandWithOutput(diffCmd)
if err != nil {
- t.Fatalf("failed to run diff: %s %v", out, err)
+ c.Fatalf("failed to run diff: %s %v", out, err)
}
found := false
@@ -31,15 +32,12 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
}
}
if !found {
- t.Errorf("couldn't find the new file in docker diff's output: %v", out)
+ c.Errorf("couldn't find the new file in docker diff's output: %v", out)
}
- deleteContainer(cleanCID)
-
- logDone("diff - check if created file shows up")
}
// test to ensure GH #3840 doesn't occur any more
-func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
+func (s *DockerSuite) TestDiffEnsureDockerinitFilesAreIgnored(c *check.C) {
// this is a list of files which shouldn't show up in `docker diff`
dockerinitFiles := []string{"/etc/resolv.conf", "/etc/hostname", "/etc/hosts", "/.dockerinit", "/.dockerenv"}
@@ -49,7 +47,7 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
out, _, err := runCommandWithOutput(runCmd)
if err != nil {
- t.Fatal(out, err)
+ c.Fatal(out, err)
}
cleanCID := strings.TrimSpace(out)
@@ -57,26 +55,22 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
out, _, err = runCommandWithOutput(diffCmd)
if err != nil {
- t.Fatalf("failed to run diff: %s, %v", out, err)
+ c.Fatalf("failed to run diff: %s, %v", out, err)
}
- deleteContainer(cleanCID)
-
for _, filename := range dockerinitFiles {
if strings.Contains(out, filename) {
- t.Errorf("found file which should've been ignored %v in diff output", filename)
+ c.Errorf("found file which should've been ignored %v in diff output", filename)
}
}
}
-
- logDone("diff - check if ignored files show up in diff")
}
-func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
+func (s *DockerSuite) TestDiffEnsureOnlyKmsgAndPtmx(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep", "0")
out, _, err := runCommandWithOutput(runCmd)
if err != nil {
- t.Fatal(out, err)
+ c.Fatal(out, err)
}
cleanCID := strings.TrimSpace(out)
@@ -84,9 +78,8 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
out, _, err = runCommandWithOutput(diffCmd)
if err != nil {
- t.Fatalf("failed to run diff: %s, %v", out, err)
+ c.Fatalf("failed to run diff: %s, %v", out, err)
}
- deleteContainer(cleanCID)
expected := map[string]bool{
"C /dev": true,
@@ -109,9 +102,7 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
for _, line := range strings.Split(out, "\n") {
if line != "" && !expected[line] {
- t.Errorf("%q is shown in the diff but shouldn't", line)
+ c.Errorf("%q is shown in the diff but shouldn't", line)
}
}
-
- logDone("diff - ensure that only kmsg and ptmx in diff")
}