- comment := check.Commentf("Expected message when creating exec command with no Cmd specified")
- c.Assert(getErrorMessage(c, b), checker.Contains, "No exec command specified", comment)
+ assert.NilError(c, err)
+ assert.Assert(c, strings.Contains(getErrorMessage(c, b), "No exec command specified"), "Expected message when creating exec command with no Cmd specified")
}
}
func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) {
func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) {
@@ -50,17 +49,15 @@ func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) {
- comment := check.Commentf("Expected message when creating exec command with Container %s is paused", name)
- c.Assert(err.Error(), checker.Contains, "Container "+name+" is paused, unpause the container before exec", comment)
+ assert.ErrorContains(c, err, "Container "+name+" is paused, unpause the container before exec", "Expected message when creating exec command with Container %s is paused", name)
}
}
func (s *DockerSuite) TestExecAPIStart(c *check.C) {
func (s *DockerSuite) TestExecAPIStart(c *check.C) {
@@ -93,7 +88,7 @@ func (s *DockerSuite) TestExecAPIStart(c *check.C) {
var execJSON struct{ PID int }
var execJSON struct{ PID int }
inspectExec(c, id, &execJSON)
inspectExec(c, id, &execJSON)
- c.Assert(execJSON.PID, checker.GreaterThan, 1)
+ assert.Assert(c, execJSON.PID > 1)
id = createExec(c, "test")
id = createExec(c, "test")
dockerCmd(c, "stop", "test")
dockerCmd(c, "stop", "test")
@@ -117,8 +112,8 @@ func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *check.C) {
- check.Commentf("Stats JSON blob from API %s %#v does not look like a <v1.21 API stats structure", apiVersion, statsJSONBlob))
+ assert.Assert(c, jsonBlobHasLTv121NetworkStats(statsJSONBlob), "Stats JSON blob from API %s %#v does not look like a <v1.21 API stats structure", apiVersion, statsJSONBlob)
- check.Commentf("Stats JSON blob from API %s %#v does not look like a >=v1.21 API stats structure", apiVersion, statsJSONBlob))
+ assert.Assert(c, jsonBlobHasGTE121NetworkStats(statsJSONBlob), "Stats JSON blob from API %s %#v does not look like a >=v1.21 API stats structure", apiVersion, statsJSONBlob)
expected := fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", version, api.MinVersion)
expected := fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", version, api.MinVersion)
func (s *DockerSuite) TestEventsFilters(c *check.C) {
func (s *DockerSuite) TestEventsFilters(c *check.C) {
@@ -281,8 +257,7 @@ func (s *DockerSuite) TestEventsFilters(c *check.C) {
// make sure we at least got 2 start events
// make sure we at least got 2 start events
count := strings.Count(out, "start")
count := strings.Count(out, "start")
- c.Assert(strings.Count(out, "start"), checker.GreaterOrEqualThan, 2, check.Commentf("should have had 2 start events but had %d, out: %s", count, out))
-
+ assert.Assert(c, count >= 2, "should have had 2 start events but had %d, out: %s", count, out)
}
}
func (s *DockerSuite) TestEventsFilterImageName(c *check.C) {
func (s *DockerSuite) TestEventsFilterImageName(c *check.C) {
@@ -298,7 +273,7 @@ func (s *DockerSuite) TestEventsFilterImageName(c *check.C) {
- c.Assert(strings.TrimSpace(string(content)), checker.Equals, "success", check.Commentf("Content was not what was modified in the container", string(content)))
+ assert.Equal(c, strings.TrimSpace(string(content)), "success", "Content was not what was modified in the container", string(content))
+ assert.Assert(c, match, "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
@@ -97,13 +99,13 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
// Process the results (out, err).
// Process the results (out, err).
for record := range recordChan {
for record := range recordChan {
if len(record.option) == 0 {
if len(record.option) == 0 {
- c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out))
- c.Assert(record.out, checker.Contains, fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", record.e.repo), check.Commentf("expected image not found error messages"))
+ assert.ErrorContains(c, record.err, "", "expected non-zero exit status when pulling non-existing image: %s", record.out)
+ assert.Assert(c, strings.Contains(record.out, fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", record.e.repo)), "expected image not found error messages")
} else {
} else {
// pull -a on a nonexistent registry should fall back as well
// pull -a on a nonexistent registry should fall back as well
- c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out))
- c.Assert(record.out, checker.Contains, fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", record.e.repo), check.Commentf("expected image not found error messages"))
- c.Assert(record.out, checker.Not(checker.Contains), "unauthorized", check.Commentf(`message should not contain "unauthorized"`))
+ assert.ErrorContains(c, record.err, "", "expected non-zero exit status when pulling non-existing image: %s", record.out)
+ assert.Assert(c, strings.Contains(record.out, fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", record.e.repo)), "expected image not found error messages")
+ assert.Assert(c, !strings.Contains(record.out, "unauthorized"), `message should not contain "unauthorized"`)
}
}
}
}
@@ -168,7 +170,7 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *chec
- c.Assert(linesCount, checker.GreaterThan, 2, check.Commentf("pulling all tags should provide more than two images, got %s", outImageAllTagCmd))
+ assert.Assert(c, linesCount > 2, "pulling all tags should provide more than two images, got %s", outImageAllTagCmd)
// Verify that the line for 'dockercore/engine-pull-all-test-fixture:latest' is left unchanged.
// Verify that the line for 'dockercore/engine-pull-all-test-fixture:latest' is left unchanged.
var latestLine string
var latestLine string
@@ -211,7 +214,7 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
break
break
}
}
}
}
- c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for dockercore/engine-pull-all-test-fixture:latest found after pulling all tags"))
+ assert.Assert(c, latestLine != "", "no entry for dockercore/engine-pull-all-test-fixture:latest found after pulling all tags")
@@ -228,7 +231,7 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
splitCurrent[4] = ""
splitCurrent[4] = ""
splitCurrent[5] = ""
splitCurrent[5] = ""
- c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("dockercore/engine-pull-all-test-fixture:latest was changed after pulling all tags"))
+ assert.Assert(c, is.DeepEqual(splitLatest, splitCurrent), "dockercore/engine-pull-all-test-fixture:latest was changed after pulling all tags")
}
}
// TestPullClientDisconnect kills the client during a pull operation and verifies that the operation
// TestPullClientDisconnect kills the client during a pull operation and verifies that the operation
@@ -241,34 +244,34 @@ func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) {
pullCmd := s.MakeCmd("pull", repoName)
pullCmd := s.MakeCmd("pull", repoName)
stdout, err := pullCmd.StdoutPipe()
stdout, err := pullCmd.StdoutPipe()
- c.Assert(err, checker.IsNil)
+ assert.NilError(c, err)
err = pullCmd.Start()
err = pullCmd.Start()
- c.Assert(err, checker.IsNil)
+ assert.NilError(c, err)
go pullCmd.Wait()
go pullCmd.Wait()
// Cancel as soon as we get some output.
// Cancel as soon as we get some output.
buf := make([]byte, 10)
buf := make([]byte, 10)
_, err = stdout.Read(buf)
_, err = stdout.Read(buf)
- c.Assert(err, checker.IsNil)
+ assert.NilError(c, err)
err = pullCmd.Process.Kill()
err = pullCmd.Process.Kill()
- c.Assert(err, checker.IsNil)
+ assert.NilError(c, err)
time.Sleep(2 * time.Second)
time.Sleep(2 * time.Second)
_, err = s.CmdWithError("inspect", repoName)
_, err = s.CmdWithError("inspect", repoName)
- c.Assert(err, checker.NotNil, check.Commentf("image was pulled after client disconnected"))
+ assert.ErrorContains(c, err, "", "image was pulled after client disconnected")
}
}
// Regression test for https://github.com/docker/docker/issues/26429
// Regression test for https://github.com/docker/docker/issues/26429
func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) {
func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) {
testRequires(c, DaemonIsWindows, Network)
testRequires(c, DaemonIsWindows, Network)
_, _, err := dockerCmdWithError("pull", "ubuntu")
_, _, err := dockerCmdWithError("pull", "ubuntu")
- c.Assert(err.Error(), checker.Contains, "no matching manifest")
+ assert.ErrorContains(c, err, "no matching manifest")
}
}
// Regression test for https://github.com/docker/docker/issues/28892
// Regression test for https://github.com/docker/docker/issues/28892
func (s *DockerSuite) TestPullWindowsImageFailsOnLinux(c *check.C) {
func (s *DockerSuite) TestPullWindowsImageFailsOnLinux(c *check.C) {
expected := fmt.Sprintf("Error response from daemon: Requested CPUs are not available - requested %s, available: %s", strconv.Itoa(invalid), sysInfo.Cpus)
expected := fmt.Sprintf("Error response from daemon: Requested CPUs are not available - requested %s, available: %s", strconv.Itoa(invalid), sysInfo.Cpus)
expected := fmt.Sprintf("Error response from daemon: Requested memory nodes are not available - requested %s, available: %s", strconv.Itoa(invalid), sysInfo.Mems)
expected := fmt.Sprintf("Error response from daemon: Requested memory nodes are not available - requested %s, available: %s", strconv.Itoa(invalid), sysInfo.Mems)
@@ -251,7 +253,7 @@ func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *check.C) {
sort.Strings(actual)
sort.Strings(actual)
sort.Strings(expected)
sort.Strings(expected)
- c.Assert(actual, checker.DeepEquals, expected, check.Commentf("archive does not contains the right layers: got %v, expected %v, output: %q", actual, expected, out))
+ assert.Assert(c, is.DeepEqual(actual, expected), "archive does not contains the right layers: got %v, expected %v, output: %q", actual, expected, out)
}
}
// Issue #6722 #5892 ensure directories are included in changes
// Issue #6722 #5892 ensure directories are included in changes
@@ -275,10 +277,10 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *check.C) {
+ assert.Assert(c, len(outSearchCmd) <= len(outSearchCmdNotrunc), "The no-trunc option can't take effect.")
outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image.
outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image.
- c.Assert(strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an AUTOMATED image: %s", outSearchCmdautomated))
+ assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated)
}
}
outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") //The busybox is a busybox base image, official image.
outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") //The busybox is a busybox base image, official image.
- c.Assert(strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial))
+ assert.Assert(c, !strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), "The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial)
}
}
outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") //The busybox is a busybox base image, official image.
outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") //The busybox is a busybox base image, official image.
- c.Assert(strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), check.Equals, true, check.Commentf("The busybox is an OFFICIAL image: %s", outSearchCmdNotOfficial))
- c.Assert(strings.Count(outSearchCmdStars, "[OK]") > strings.Count(outSearchCmd, "[OK]"), check.Equals, false, check.Commentf("The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars))
+ assert.Assert(c, strings.Count(outSearchCmdStars, "[OK]") <= strings.Count(outSearchCmd, "[OK]"), "The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars)
- c.Assert(strings.HasPrefix(outSearchCmdautomatedSlice1[i], "busybox "), check.Equals, false, check.Commentf("The busybox is not an AUTOMATED image: %s", outSearchCmdautomated))
+ assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice1[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated)
- c.Assert(strings.Count(outSearchCmdStars1, "[OK]") > strings.Count(outSearchCmd, "[OK]"), check.Equals, false, check.Commentf("The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars1))
+ assert.Assert(c, strings.Count(outSearchCmdStars1, "[OK]") <= strings.Count(outSearchCmd, "[OK]"), "The quantity of images with stars should be less than that of all images: %s", outSearchCmdStars1)
- c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out))
+ assert.ErrorContains(c, err, "")
+ assert.Assert(c, is.Contains(out, "No such container: notfound"), "Expected to fail on not found container stats with --no-stream, got %q instead", out)
}
}
func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
@@ -60,13 +61,13 @@ func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
@@ -40,8 +40,8 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
lookingFor = "top"
lookingFor = "top"
}
}
- c.Assert(out1, checker.Contains, lookingFor, check.Commentf("top should've listed `%s` in the process list, but failed the first time", lookingFor))
- c.Assert(out2, checker.Contains, lookingFor, check.Commentf("top should've listed `%s` in the process list, but failed the second time", lookingFor))
+ assert.Assert(c, strings.Contains(out1, lookingFor), "top should've listed `%s` in the process list, but failed the first time", lookingFor)
+ assert.Assert(c, strings.Contains(out2, lookingFor), "top should've listed `%s` in the process list, but failed the second time", lookingFor)
}
}
// TestTopWindowsCoreProcesses validates that there are lines for the critical
// TestTopWindowsCoreProcesses validates that there are lines for the critical
@@ -54,7 +54,7 @@ func (s *DockerSuite) TestTopWindowsCoreProcesses(c *check.C) {
- c.Assert(string(buf), checker.Contains, "Duplicate mount point", check.Commentf("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err))
+ assert.Assert(c, strings.Contains(string(buf), "Duplicate mount point"), "Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err)
}
}
func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) {
func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) {
@@ -115,21 +116,21 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) {
- c.Assert(pth, checker.Equals, pth2, check.Commentf("expected volume host path to be %s, got %s", pth, pth2))
+ assert.NilError(c, err)
+ assert.Equal(c, pth, pth2, "expected volume host path to be %s, got %s", pth, pth2)
}
}
// #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume
// #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume
@@ -139,18 +140,18 @@ func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *check.C) {