Browse code

Windows: Port a docker diff test

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/10/29 04:21:54
Showing 1 changed files
... ...
@@ -2,6 +2,7 @@ package main
2 2
 
3 3
 import (
4 4
 	"strings"
5
+	"time"
5 6
 
6 7
 	"github.com/docker/docker/pkg/integration/checker"
7 8
 	"github.com/go-check/check"
... ...
@@ -9,16 +10,27 @@ import (
9 9
 
10 10
 // ensure that an added file shows up in docker diff
11 11
 func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
12
-	testRequires(c, DaemonIsLinux)
13
-	containerCmd := `echo foo > /root/bar`
12
+	containerCmd := `mkdir /foo; echo xyzzy > /foo/bar`
14 13
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", containerCmd)
15 14
 
15
+	// Wait for it to exit as cannot diff a running container on Windows, and
16
+	// it will take a few seconds to exit. Also there's no way in Windows to
17
+	// differentiate between an Add or a Modify, and all files are under
18
+	// a "Files/" prefix.
19
+	containerID := strings.TrimSpace(out)
20
+	lookingFor := "A /foo/bar"
21
+	if daemonPlatform == "windows" {
22
+		err := waitExited(containerID, 60*time.Second)
23
+		c.Assert(err, check.IsNil)
24
+		lookingFor = "C Files/foo/bar"
25
+	}
26
+
16 27
 	cleanCID := strings.TrimSpace(out)
17 28
 	out, _ = dockerCmd(c, "diff", cleanCID)
18 29
 
19 30
 	found := false
20 31
 	for _, line := range strings.Split(out, "\n") {
21
-		if strings.Contains("A /root/bar", line) {
32
+		if strings.Contains(line, lookingFor) {
22 33
 			found = true
23 34
 			break
24 35
 		}