summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Goff <cpuguy83@gmail.com>2015-10-24 08:14:08 -0400
committerBrian Goff <cpuguy83@gmail.com>2015-10-24 08:14:08 -0400
commit80439a4ce280777ded1b22842b7b6b3d4d6b574a (patch)
treefdbd66e25c5c54ce5443597162564deab207e68e
parentc3ea74f6869b179ee0803b94448d6af3164a6002 (diff)
parent04b6b0b47fab7751b716b0b6c8ce3b98a8c51e99 (diff)
downloaddocker-80439a4ce280777ded1b22842b7b6b3d4d6b574a.tar.gz
Merge pull request #17296 from jecarey/16756-docker_cli_history_test
Use of checkers on docker_cli_history_test.go
-rw-r--r--integration-cli/docker_cli_history_test.go31
1 files changed, 10 insertions, 21 deletions
diff --git a/integration-cli/docker_cli_history_test.go b/integration-cli/docker_cli_history_test.go
index ce9d902ed7..4dc0bb8b11 100644
--- a/integration-cli/docker_cli_history_test.go
+++ b/integration-cli/docker_cli_history_test.go
@@ -6,6 +6,7 @@ import (
"strconv"
"strings"
+ "github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
)
@@ -43,9 +44,7 @@ RUN echo "Y"
RUN echo "Z"`,
true)
- if err != nil {
- c.Fatal(err)
- }
+ c.Assert(err, checker.IsNil)
out, _ := dockerCmd(c, "history", "testbuildhistory")
actualValues := strings.Split(out, "\n")[1:27]
@@ -54,10 +53,7 @@ RUN echo "Z"`,
for i := 0; i < 26; i++ {
echoValue := fmt.Sprintf("echo \"%s\"", expectedValues[i])
actualValue := actualValues[i]
-
- if !strings.Contains(actualValue, echoValue) {
- c.Fatalf("Expected layer \"%s\", but was: %s", expectedValues[i], actualValue)
- }
+ c.Assert(actualValue, checker.Contains, echoValue)
}
}
@@ -69,9 +65,7 @@ func (s *DockerSuite) TestHistoryExistentImage(c *check.C) {
func (s *DockerSuite) TestHistoryNonExistentImage(c *check.C) {
_, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage")
- if err == nil {
- c.Fatal("history on a non-existent image should fail.")
- }
+ c.Assert(err, checker.NotNil, check.Commentf("history on a non-existent image should fail."))
}
func (s *DockerSuite) TestHistoryImageWithComment(c *check.C) {
@@ -91,10 +85,7 @@ func (s *DockerSuite) TestHistoryImageWithComment(c *check.C) {
out, _ := dockerCmd(c, "history", name)
outputTabs := strings.Fields(strings.Split(out, "\n")[1])
actualValue := outputTabs[len(outputTabs)-1]
-
- if !strings.Contains(actualValue, comment) {
- c.Fatalf("Expected comments %q, but found %q", comment, actualValue)
- }
+ c.Assert(actualValue, checker.Contains, comment)
}
func (s *DockerSuite) TestHistoryHumanOptionFalse(c *check.C) {
@@ -110,9 +101,9 @@ func (s *DockerSuite) TestHistoryHumanOptionFalse(c *check.C) {
endIndex = len(lines[i])
}
sizeString := lines[i][startIndex:endIndex]
- if _, err := strconv.Atoi(strings.TrimSpace(sizeString)); err != nil {
- c.Fatalf("The size '%s' was not an Integer", sizeString)
- }
+
+ _, err := strconv.Atoi(strings.TrimSpace(sizeString))
+ c.Assert(err, checker.IsNil, check.Commentf("The size '%s' was not an Integer", sizeString))
}
}
@@ -121,7 +112,7 @@ func (s *DockerSuite) TestHistoryHumanOptionTrue(c *check.C) {
out, _ := dockerCmd(c, "history", "--human=true", "busybox")
lines := strings.Split(out, "\n")
sizeColumnRegex, _ := regexp.Compile("SIZE +")
- humanSizeRegex, _ := regexp.Compile("^\\d+.*B$") // Matches human sizes like 10 MB, 3.2 KB, etc
+ humanSizeRegexRaw := "\\d+.*B" // Matches human sizes like 10 MB, 3.2 KB, etc
indices := sizeColumnRegex.FindStringIndex(lines[0])
startIndex := indices[0]
endIndex := indices[1]
@@ -130,8 +121,6 @@ func (s *DockerSuite) TestHistoryHumanOptionTrue(c *check.C) {
endIndex = len(lines[i])
}
sizeString := lines[i][startIndex:endIndex]
- if matchSuccess := humanSizeRegex.MatchString(strings.TrimSpace(sizeString)); !matchSuccess {
- c.Fatalf("The size '%s' was not in human format", sizeString)
- }
+ c.Assert(strings.TrimSpace(sizeString), checker.Matches, humanSizeRegexRaw, check.Commentf("The size '%s' was not in human format", sizeString))
}
}