Merge pull request #27867 from Microsoft/jjh/difftest

Windows: Port a docker diff test
This commit is contained in:
Sebastiaan van Stijn 2016-10-28 16:44:03 -07:00 committed by GitHub
commit a0eae7e3c0
1 changed files with 15 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"strings"
"time"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
@ -9,16 +10,27 @@ import (
// ensure that an added file shows up in docker diff
func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
testRequires(c, DaemonIsLinux)
containerCmd := `echo foo > /root/bar`
containerCmd := `mkdir /foo; echo xyzzy > /foo/bar`
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", containerCmd)
// Wait for it to exit as cannot diff a running container on Windows, and
// it will take a few seconds to exit. Also there's no way in Windows to
// differentiate between an Add or a Modify, and all files are under
// a "Files/" prefix.
containerID := strings.TrimSpace(out)
lookingFor := "A /foo/bar"
if daemonPlatform == "windows" {
err := waitExited(containerID, 60*time.Second)
c.Assert(err, check.IsNil)
lookingFor = "C Files/foo/bar"
}
cleanCID := strings.TrimSpace(out)
out, _ = dockerCmd(c, "diff", cleanCID)
found := false
for _, line := range strings.Split(out, "\n") {
if strings.Contains("A /root/bar", line) {
if strings.Contains(line, lookingFor) {
found = true
break
}