mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use of checkers in docker_cli_pull_test.go
Signed-off-by: James Carey <jecarey@us.ibm.com>
This commit is contained in:
parent
8537501ebd
commit
1b010516d0
1 changed files with 11 additions and 17 deletions
|
@ -29,11 +29,9 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *check.C) {
|
||||||
|
|
||||||
// We should have a single entry in images.
|
// We should have a single entry in images.
|
||||||
img := strings.TrimSpace(s.Cmd(c, "images"))
|
img := strings.TrimSpace(s.Cmd(c, "images"))
|
||||||
if splitImg := strings.Split(img, "\n"); len(splitImg) != 2 {
|
splitImg := strings.Split(img, "\n")
|
||||||
c.Fatalf("expected only two lines in the output of `docker images`, got %d", len(splitImg))
|
c.Assert(splitImg, checker.HasLen, 2)
|
||||||
} else if re := regexp.MustCompile(`^hello-world\s+latest`); !re.Match([]byte(splitImg[1])) {
|
c.Assert(splitImg[1], checker.Matches, `hello-world\s+latest.*?`, check.Commentf("invalid output for `docker images` (expected image and tag name"))
|
||||||
c.Fatal("invalid output for `docker images` (expected image and tag name")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPullNonExistingImage pulls non-existing images from the central registry, with different
|
// TestPullNonExistingImage pulls non-existing images from the central registry, with different
|
||||||
|
@ -81,11 +79,9 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *chec
|
||||||
|
|
||||||
// We should have a single entry in images.
|
// We should have a single entry in images.
|
||||||
img := strings.TrimSpace(s.Cmd(c, "images"))
|
img := strings.TrimSpace(s.Cmd(c, "images"))
|
||||||
if splitImg := strings.Split(img, "\n"); len(splitImg) != 2 {
|
splitImg := strings.Split(img, "\n")
|
||||||
c.Fatalf("expected only two lines in the output of `docker images`, got %d", len(splitImg))
|
c.Assert(splitImg, checker.HasLen, 2)
|
||||||
} else if re := regexp.MustCompile(`^hello-world\s+latest`); !re.Match([]byte(splitImg[1])) {
|
c.Assert(splitImg[1], checker.Matches, `hello-world\s+latest.*?`, check.Commentf("invalid output for `docker images` (expected image and tag name"))
|
||||||
c.Fatal("invalid output for `docker images` (expected image and tag name")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPullScratchNotAllowed verifies that pulling 'scratch' is rejected.
|
// TestPullScratchNotAllowed verifies that pulling 'scratch' is rejected.
|
||||||
|
@ -104,13 +100,12 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
|
||||||
s.Cmd(c, "pull", "busybox")
|
s.Cmd(c, "pull", "busybox")
|
||||||
outImageCmd := s.Cmd(c, "images", "busybox")
|
outImageCmd := s.Cmd(c, "images", "busybox")
|
||||||
splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n")
|
splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n")
|
||||||
c.Assert(splitOutImageCmd, checker.HasLen, 2, check.Commentf("expected a single entry in images\n%v", outImageCmd))
|
c.Assert(splitOutImageCmd, checker.HasLen, 2)
|
||||||
|
|
||||||
s.Cmd(c, "pull", "--all-tags=true", "busybox")
|
s.Cmd(c, "pull", "--all-tags=true", "busybox")
|
||||||
outImageAllTagCmd := s.Cmd(c, "images", "busybox")
|
outImageAllTagCmd := s.Cmd(c, "images", "busybox")
|
||||||
if linesCount := strings.Count(outImageAllTagCmd, "\n"); linesCount <= 2 {
|
linesCount := strings.Count(outImageAllTagCmd, "\n")
|
||||||
c.Fatalf("pulling all tags should provide more images, got %d", linesCount-1)
|
c.Assert(linesCount, checker.GreaterThan, 2, check.Commentf("pulling all tags should provide more than two images, got %s", outImageAllTagCmd))
|
||||||
}
|
|
||||||
|
|
||||||
// Verify that the line for 'busybox:latest' is left unchanged.
|
// Verify that the line for 'busybox:latest' is left unchanged.
|
||||||
var latestLine string
|
var latestLine string
|
||||||
|
@ -162,7 +157,6 @@ func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
if _, err := s.CmdWithError("inspect", repoName); err == nil {
|
_, err = s.CmdWithError("inspect", repoName)
|
||||||
c.Fatal("image was pulled after client disconnected")
|
c.Assert(err, checker.NotNil, check.Commentf("image was pulled after client disconnected"))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue