mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
integration-cli: remove unneeded fmt.Sprintf() in asserts
Replaced using a bit of grep-ing; ``` find . -name "*_test.go" -exec sed -E -i 's#assert.Assert\((.*), fmt.Sprintf\((.*)\)\)$#assert.Assert\(\1, \2\)#g' '{}' \; ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -252,7 +252,7 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
|
||||
|
||||
// make sure repo shown, tag=<none>, digest = $digest1
|
||||
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`)
|
||||
assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out))
|
||||
assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
|
||||
// setup image2
|
||||
digest2, err := setupImageWithTag(c, "tag2")
|
||||
//error setting up image
|
||||
@ -270,11 +270,11 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
|
||||
out, _ = dockerCmd(c, "images", "--digests")
|
||||
|
||||
// make sure repo shown, tag=<none>, digest = $digest1
|
||||
assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out))
|
||||
assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
|
||||
|
||||
// make sure repo shown, tag=<none>, digest = $digest2
|
||||
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`)
|
||||
assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out))
|
||||
assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
|
||||
|
||||
// pull tag1
|
||||
dockerCmd(c, "pull", repoName+":tag1")
|
||||
@ -284,9 +284,9 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
|
||||
|
||||
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest
|
||||
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*tag1\s*` + digest1.String() + `\s`)
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out))
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
|
||||
// make sure image 2 has repo, <none>, digest
|
||||
assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out))
|
||||
assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
|
||||
|
||||
// pull tag 2
|
||||
dockerCmd(c, "pull", repoName+":tag2")
|
||||
@ -295,22 +295,22 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
|
||||
out, _ = dockerCmd(c, "images", "--digests")
|
||||
|
||||
// make sure image 1 has repo, tag, digest
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out))
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
|
||||
|
||||
// make sure image 2 has repo, tag, digest
|
||||
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*tag2\s*` + digest2.String() + `\s`)
|
||||
assert.Assert(c, reWithDigest2.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest2.String(), out))
|
||||
assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out)
|
||||
|
||||
// list images
|
||||
out, _ = dockerCmd(c, "images", "--digests")
|
||||
|
||||
// make sure image 1 has repo, tag, digest
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out))
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
|
||||
// make sure image 2 has repo, tag, digest
|
||||
assert.Assert(c, reWithDigest2.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest2.String(), out))
|
||||
assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out)
|
||||
// make sure busybox has tag, but not digest
|
||||
busyboxRe := regexp.MustCompile(`\s*busybox\s*latest\s*<none>\s`)
|
||||
assert.Assert(c, busyboxRe.MatchString(out), fmt.Sprintf("expected %q: %s", busyboxRe.String(), out))
|
||||
assert.Assert(c, busyboxRe.MatchString(out), "expected %q: %s", busyboxRe.String(), out)
|
||||
}
|
||||
|
||||
func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
|
||||
@ -328,7 +328,7 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
|
||||
|
||||
// make sure repo shown, tag=<none>, digest = $digest1
|
||||
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`)
|
||||
assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out))
|
||||
assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
|
||||
// setup image2
|
||||
digest2, err := setupImageWithTag(c, "dangle2")
|
||||
//error setting up image
|
||||
@ -346,11 +346,11 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
|
||||
out, _ = dockerCmd(c, "images", "--digests", "--filter=dangling=true")
|
||||
|
||||
// make sure repo shown, tag=<none>, digest = $digest1
|
||||
assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out))
|
||||
assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
|
||||
|
||||
// make sure repo shown, tag=<none>, digest = $digest2
|
||||
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`)
|
||||
assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out))
|
||||
assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
|
||||
|
||||
// pull dangle1 tag
|
||||
dockerCmd(c, "pull", repoName+":dangle1")
|
||||
@ -360,9 +360,9 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
|
||||
|
||||
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest
|
||||
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*dangle1\s*` + digest1.String() + `\s`)
|
||||
assert.Assert(c, !reWithDigest1.MatchString(out), fmt.Sprintf("unexpected %q: %s", reWithDigest1.String(), out))
|
||||
assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out)
|
||||
// make sure image 2 has repo, <none>, digest
|
||||
assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out))
|
||||
assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
|
||||
|
||||
// pull dangle2 tag
|
||||
dockerCmd(c, "pull", repoName+":dangle2")
|
||||
@ -371,19 +371,19 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
|
||||
out, _ = dockerCmd(c, "images", "--digests")
|
||||
|
||||
// make sure image 1 has repo, tag, digest
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out))
|
||||
assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
|
||||
|
||||
// make sure image 2 has repo, tag, digest
|
||||
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*dangle2\s*` + digest2.String() + `\s`)
|
||||
assert.Assert(c, reWithDigest2.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest2.String(), out))
|
||||
assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out)
|
||||
|
||||
// list images, no longer dangling, should not match
|
||||
out, _ = dockerCmd(c, "images", "--digests", "--filter=dangling=true")
|
||||
|
||||
// make sure image 1 has repo, tag, digest
|
||||
assert.Assert(c, !reWithDigest1.MatchString(out), fmt.Sprintf("unexpected %q: %s", reWithDigest1.String(), out))
|
||||
assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out)
|
||||
// make sure image 2 has repo, tag, digest
|
||||
assert.Assert(c, !reWithDigest2.MatchString(out), fmt.Sprintf("unexpected %q: %s", reWithDigest2.String(), out))
|
||||
assert.Assert(c, !reWithDigest2.MatchString(out), "unexpected %q: %s", reWithDigest2.String(), out)
|
||||
}
|
||||
|
||||
func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) {
|
||||
@ -643,7 +643,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
|
||||
assert.Assert(c, exitStatus != 0, "expected a non-zero exit status")
|
||||
|
||||
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg), fmt.Sprintf("expected error message in output: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out)
|
||||
}
|
||||
|
||||
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
|
||||
@ -686,5 +686,5 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T)
|
||||
assert.Assert(c, exitStatus != 0, "expected a non-zero exit status")
|
||||
|
||||
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg), fmt.Sprintf("expected error message in output: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out)
|
||||
}
|
||||
|
Reference in New Issue
Block a user