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>
(cherry picked from commit 0fabf3e41ec3cc0ba5479ce91e278c1e7855eebd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
... | ... |
@@ -1220,7 +1220,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) { |
1220 | 1220 |
assert.NilError(c, err) |
1221 | 1221 |
|
1222 | 1222 |
_, err = os.Stat(source) |
1223 |
- assert.Assert(c, os.IsNotExist(err), fmt.Sprintf("expected to get ErrNotExist error, got %v", err)) |
|
1223 |
+ assert.Assert(c, os.IsNotExist(err), "expected to get ErrNotExist error, got %v", err) |
|
1224 | 1224 |
} |
1225 | 1225 |
|
1226 | 1226 |
// Regression test for https://github.com/docker/docker/issues/6231 |
... | ... |
@@ -4,7 +4,6 @@ package main |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"bufio" |
7 |
- "fmt" |
|
8 | 7 |
"io/ioutil" |
9 | 8 |
"os/exec" |
10 | 9 |
"strings" |
... | ... |
@@ -52,7 +51,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) { |
52 | 52 |
case err := <-errChan: |
53 | 53 |
tty.Close() |
54 | 54 |
out, _ := ioutil.ReadAll(pty) |
55 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", string(out))) |
|
55 |
+ assert.Assert(c, err == nil, "out: %v", string(out)) |
|
56 | 56 |
case <-time.After(attachWait): |
57 | 57 |
c.Fatal("timed out without attach returning") |
58 | 58 |
} |
... | ... |
@@ -4738,7 +4738,7 @@ func (s *DockerSuite) TestBuildTagEvent(c *testing.T) { |
4738 | 4738 |
} |
4739 | 4739 |
} |
4740 | 4740 |
|
4741 |
- assert.Assert(c, foundTag, fmt.Sprintf("No tag event found:\n%s", out)) |
|
4741 |
+ assert.Assert(c, foundTag, "No tag event found:\n%s", out) |
|
4742 | 4742 |
} |
4743 | 4743 |
|
4744 | 4744 |
// #15780 |
... | ... |
@@ -252,7 +252,7 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) { |
252 | 252 |
|
253 | 253 |
// make sure repo shown, tag=<none>, digest = $digest1 |
254 | 254 |
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`) |
255 |
- assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out)) |
|
255 |
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
256 | 256 |
// setup image2 |
257 | 257 |
digest2, err := setupImageWithTag(c, "tag2") |
258 | 258 |
//error setting up image |
... | ... |
@@ -270,11 +270,11 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) { |
270 | 270 |
out, _ = dockerCmd(c, "images", "--digests") |
271 | 271 |
|
272 | 272 |
// make sure repo shown, tag=<none>, digest = $digest1 |
273 |
- assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out)) |
|
273 |
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
274 | 274 |
|
275 | 275 |
// make sure repo shown, tag=<none>, digest = $digest2 |
276 | 276 |
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`) |
277 |
- assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out)) |
|
277 |
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
278 | 278 |
|
279 | 279 |
// pull tag1 |
280 | 280 |
dockerCmd(c, "pull", repoName+":tag1") |
... | ... |
@@ -284,9 +284,9 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) { |
284 | 284 |
|
285 | 285 |
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest |
286 | 286 |
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*tag1\s*` + digest1.String() + `\s`) |
287 |
- assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out)) |
|
287 |
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
288 | 288 |
// make sure image 2 has repo, <none>, digest |
289 |
- assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out)) |
|
289 |
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
290 | 290 |
|
291 | 291 |
// pull tag 2 |
292 | 292 |
dockerCmd(c, "pull", repoName+":tag2") |
... | ... |
@@ -295,22 +295,22 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) { |
295 | 295 |
out, _ = dockerCmd(c, "images", "--digests") |
296 | 296 |
|
297 | 297 |
// make sure image 1 has repo, tag, digest |
298 |
- assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out)) |
|
298 |
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
299 | 299 |
|
300 | 300 |
// make sure image 2 has repo, tag, digest |
301 | 301 |
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*tag2\s*` + digest2.String() + `\s`) |
302 |
- assert.Assert(c, reWithDigest2.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest2.String(), out)) |
|
302 |
+ assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
303 | 303 |
|
304 | 304 |
// list images |
305 | 305 |
out, _ = dockerCmd(c, "images", "--digests") |
306 | 306 |
|
307 | 307 |
// make sure image 1 has repo, tag, digest |
308 |
- assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out)) |
|
308 |
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
309 | 309 |
// make sure image 2 has repo, tag, digest |
310 |
- assert.Assert(c, reWithDigest2.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest2.String(), out)) |
|
310 |
+ assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
311 | 311 |
// make sure busybox has tag, but not digest |
312 | 312 |
busyboxRe := regexp.MustCompile(`\s*busybox\s*latest\s*<none>\s`) |
313 |
- assert.Assert(c, busyboxRe.MatchString(out), fmt.Sprintf("expected %q: %s", busyboxRe.String(), out)) |
|
313 |
+ assert.Assert(c, busyboxRe.MatchString(out), "expected %q: %s", busyboxRe.String(), out) |
|
314 | 314 |
} |
315 | 315 |
|
316 | 316 |
func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) { |
... | ... |
@@ -328,7 +328,7 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) { |
328 | 328 |
|
329 | 329 |
// make sure repo shown, tag=<none>, digest = $digest1 |
330 | 330 |
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`) |
331 |
- assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out)) |
|
331 |
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
332 | 332 |
// setup image2 |
333 | 333 |
digest2, err := setupImageWithTag(c, "dangle2") |
334 | 334 |
//error setting up image |
... | ... |
@@ -346,11 +346,11 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) { |
346 | 346 |
out, _ = dockerCmd(c, "images", "--digests", "--filter=dangling=true") |
347 | 347 |
|
348 | 348 |
// make sure repo shown, tag=<none>, digest = $digest1 |
349 |
- assert.Assert(c, re1.MatchString(out), fmt.Sprintf("expected %q: %s", re1.String(), out)) |
|
349 |
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
350 | 350 |
|
351 | 351 |
// make sure repo shown, tag=<none>, digest = $digest2 |
352 | 352 |
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`) |
353 |
- assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out)) |
|
353 |
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
354 | 354 |
|
355 | 355 |
// pull dangle1 tag |
356 | 356 |
dockerCmd(c, "pull", repoName+":dangle1") |
... | ... |
@@ -360,9 +360,9 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) { |
360 | 360 |
|
361 | 361 |
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest |
362 | 362 |
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*dangle1\s*` + digest1.String() + `\s`) |
363 |
- assert.Assert(c, !reWithDigest1.MatchString(out), fmt.Sprintf("unexpected %q: %s", reWithDigest1.String(), out)) |
|
363 |
+ assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out) |
|
364 | 364 |
// make sure image 2 has repo, <none>, digest |
365 |
- assert.Assert(c, re2.MatchString(out), fmt.Sprintf("expected %q: %s", re2.String(), out)) |
|
365 |
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
366 | 366 |
|
367 | 367 |
// pull dangle2 tag |
368 | 368 |
dockerCmd(c, "pull", repoName+":dangle2") |
... | ... |
@@ -371,19 +371,19 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) { |
371 | 371 |
out, _ = dockerCmd(c, "images", "--digests") |
372 | 372 |
|
373 | 373 |
// make sure image 1 has repo, tag, digest |
374 |
- assert.Assert(c, reWithDigest1.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest1.String(), out)) |
|
374 |
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
375 | 375 |
|
376 | 376 |
// make sure image 2 has repo, tag, digest |
377 | 377 |
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*dangle2\s*` + digest2.String() + `\s`) |
378 |
- assert.Assert(c, reWithDigest2.MatchString(out), fmt.Sprintf("expected %q: %s", reWithDigest2.String(), out)) |
|
378 |
+ assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
379 | 379 |
|
380 | 380 |
// list images, no longer dangling, should not match |
381 | 381 |
out, _ = dockerCmd(c, "images", "--digests", "--filter=dangling=true") |
382 | 382 |
|
383 | 383 |
// make sure image 1 has repo, tag, digest |
384 |
- assert.Assert(c, !reWithDigest1.MatchString(out), fmt.Sprintf("unexpected %q: %s", reWithDigest1.String(), out)) |
|
384 |
+ assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out) |
|
385 | 385 |
// make sure image 2 has repo, tag, digest |
386 |
- assert.Assert(c, !reWithDigest2.MatchString(out), fmt.Sprintf("unexpected %q: %s", reWithDigest2.String(), out)) |
|
386 |
+ assert.Assert(c, !reWithDigest2.MatchString(out), "unexpected %q: %s", reWithDigest2.String(), out) |
|
387 | 387 |
} |
388 | 388 |
|
389 | 389 |
func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) { |
... | ... |
@@ -643,7 +643,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) { |
643 | 643 |
assert.Assert(c, exitStatus != 0, "expected a non-zero exit status") |
644 | 644 |
|
645 | 645 |
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest) |
646 |
- assert.Assert(c, strings.Contains(out, expectedErrorMsg), fmt.Sprintf("expected error message in output: %s", out)) |
|
646 |
+ assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out) |
|
647 | 647 |
} |
648 | 648 |
|
649 | 649 |
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when |
... | ... |
@@ -686,5 +686,5 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) |
686 | 686 |
assert.Assert(c, exitStatus != 0, "expected a non-zero exit status") |
687 | 687 |
|
688 | 688 |
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest) |
689 |
- assert.Assert(c, strings.Contains(out, expectedErrorMsg), fmt.Sprintf("expected error message in output: %s", out)) |
|
689 |
+ assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out) |
|
690 | 690 |
} |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
package main |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
5 | 4 |
"strings" |
6 | 5 |
"testing" |
7 | 6 |
|
... | ... |
@@ -72,7 +71,7 @@ func (s *DockerSuite) TestCommitHardlink(c *testing.T) { |
72 | 72 |
chunks := strings.Split(strings.TrimSpace(firstOutput), " ") |
73 | 73 |
inode := chunks[0] |
74 | 74 |
chunks = strings.SplitAfterN(strings.TrimSpace(firstOutput), " ", 2) |
75 |
- assert.Assert(c, strings.Contains(chunks[1], chunks[0]), fmt.Sprintf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:])) |
|
75 |
+ assert.Assert(c, strings.Contains(chunks[1], chunks[0]), "Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]) |
|
76 | 76 |
imageID, _ := dockerCmd(c, "commit", "hardlinks", "hardlinks") |
77 | 77 |
imageID = strings.TrimSpace(imageID) |
78 | 78 |
|
... | ... |
@@ -81,7 +80,7 @@ func (s *DockerSuite) TestCommitHardlink(c *testing.T) { |
81 | 81 |
chunks = strings.Split(strings.TrimSpace(secondOutput), " ") |
82 | 82 |
inode = chunks[0] |
83 | 83 |
chunks = strings.SplitAfterN(strings.TrimSpace(secondOutput), " ", 2) |
84 |
- assert.Assert(c, strings.Contains(chunks[1], chunks[0]), fmt.Sprintf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:])) |
|
84 |
+ assert.Assert(c, strings.Contains(chunks[1], chunks[0]), "Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]) |
|
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
func (s *DockerSuite) TestCommitTTY(c *testing.T) { |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
package main |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
5 | 4 |
"os" |
6 | 5 |
"path/filepath" |
7 | 6 |
"testing" |
... | ... |
@@ -150,7 +149,7 @@ func (s *DockerSuite) TestCpFromCaseB(c *testing.T) { |
150 | 150 |
err := runDockerCp(c, srcPath, dstDir, nil) |
151 | 151 |
assert.ErrorContains(c, err, "") |
152 | 152 |
|
153 |
- assert.Assert(c, isCpDirNotExist(err), fmt.Sprintf("expected DirNotExists error, but got %T: %s", err, err)) |
|
153 |
+ assert.Assert(c, isCpDirNotExist(err), "expected DirNotExists error, but got %T: %s", err, err) |
|
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
// C. SRC specifies a file and DST exists as a file. This should overwrite |
... | ... |
@@ -195,7 +194,7 @@ func (s *DockerSuite) TestCpFromCaseD(c *testing.T) { |
195 | 195 |
|
196 | 196 |
// Ensure that dstPath doesn't exist. |
197 | 197 |
_, err := os.Stat(dstPath) |
198 |
- assert.Assert(c, os.IsNotExist(err), fmt.Sprintf("did not expect dstPath %q to exist", dstPath)) |
|
198 |
+ assert.Assert(c, os.IsNotExist(err), "did not expect dstPath %q to exist", dstPath) |
|
199 | 199 |
|
200 | 200 |
assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil) |
201 | 201 |
|
... | ... |
@@ -266,7 +265,7 @@ func (s *DockerSuite) TestCpFromCaseF(c *testing.T) { |
266 | 266 |
err := runDockerCp(c, srcDir, dstFile, nil) |
267 | 267 |
assert.ErrorContains(c, err, "") |
268 | 268 |
|
269 |
- assert.Assert(c, isCpCannotCopyDir(err), fmt.Sprintf("expected ErrCannotCopyDir error, but got %T: %s", err, err)) |
|
269 |
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err) |
|
270 | 270 |
} |
271 | 271 |
|
272 | 272 |
// G. SRC specifies a directory and DST exists as a directory. This should copy |
... | ... |
@@ -358,7 +357,7 @@ func (s *DockerSuite) TestCpFromCaseI(c *testing.T) { |
358 | 358 |
err := runDockerCp(c, srcDir, dstFile, nil) |
359 | 359 |
assert.ErrorContains(c, err, "") |
360 | 360 |
|
361 |
- assert.Assert(c, isCpCannotCopyDir(err), fmt.Sprintf("expected ErrCannotCopyDir error, but got %T: %s", err, err)) |
|
361 |
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err) |
|
362 | 362 |
} |
363 | 363 |
|
364 | 364 |
// J. SRC specifies a directory's contents only and DST exists as a directory. |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
package main |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
5 | 4 |
"os" |
6 | 5 |
"testing" |
7 | 6 |
|
... | ... |
@@ -158,7 +157,7 @@ func (s *DockerSuite) TestCpToCaseB(c *testing.T) { |
158 | 158 |
err := runDockerCp(c, srcPath, dstDir, nil) |
159 | 159 |
assert.ErrorContains(c, err, "") |
160 | 160 |
|
161 |
- assert.Assert(c, isCpDirNotExist(err), fmt.Sprintf("expected DirNotExists error, but got %T: %s", err, err)) |
|
161 |
+ assert.Assert(c, isCpDirNotExist(err), "expected DirNotExists error, but got %T: %s", err, err) |
|
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
// C. SRC specifies a file and DST exists as a file. This should overwrite |
... | ... |
@@ -288,7 +287,7 @@ func (s *DockerSuite) TestCpToCaseF(c *testing.T) { |
288 | 288 |
err := runDockerCp(c, srcDir, dstFile, nil) |
289 | 289 |
assert.ErrorContains(c, err, "") |
290 | 290 |
|
291 |
- assert.Assert(c, isCpCannotCopyDir(err), fmt.Sprintf("expected ErrCannotCopyDir error, but got %T: %s", err, err)) |
|
291 |
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err) |
|
292 | 292 |
} |
293 | 293 |
|
294 | 294 |
// G. SRC specifies a directory and DST exists as a directory. This should copy |
... | ... |
@@ -393,7 +392,7 @@ func (s *DockerSuite) TestCpToCaseI(c *testing.T) { |
393 | 393 |
err := runDockerCp(c, srcDir, dstFile, nil) |
394 | 394 |
assert.ErrorContains(c, err, "") |
395 | 395 |
|
396 |
- assert.Assert(c, isCpCannotCopyDir(err), fmt.Sprintf("expected ErrCannotCopyDir error, but got %T: %s", err, err)) |
|
396 |
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err) |
|
397 | 397 |
} |
398 | 398 |
|
399 | 399 |
// J. SRC specifies a directory's contents only and DST exists as a directory. |
... | ... |
@@ -462,7 +461,7 @@ func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *testing.T) { |
462 | 462 |
err := runDockerCp(c, srcPath, dstPath, nil) |
463 | 463 |
assert.ErrorContains(c, err, "") |
464 | 464 |
|
465 |
- assert.Assert(c, isCpCannotCopyReadOnly(err), fmt.Sprintf("expected ErrContainerRootfsReadonly error, but got %T: %s", err, err)) |
|
465 |
+ assert.Assert(c, isCpCannotCopyReadOnly(err), "expected ErrContainerRootfsReadonly error, but got %T: %s", err, err) |
|
466 | 466 |
|
467 | 467 |
// Ensure that dstPath doesn't exist. |
468 | 468 |
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil) |
... | ... |
@@ -489,7 +488,7 @@ func (s *DockerSuite) TestCpToErrReadOnlyVolume(c *testing.T) { |
489 | 489 |
err := runDockerCp(c, srcPath, dstPath, nil) |
490 | 490 |
assert.ErrorContains(c, err, "") |
491 | 491 |
|
492 |
- assert.Assert(c, isCpCannotCopyReadOnly(err), fmt.Sprintf("expected ErrVolumeReadonly error, but got %T: %s", err, err)) |
|
492 |
+ assert.Assert(c, isCpCannotCopyReadOnly(err), "expected ErrVolumeReadonly error, but got %T: %s", err, err) |
|
493 | 493 |
|
494 | 494 |
// Ensure that dstPath doesn't exist. |
495 | 495 |
assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil) |
... | ... |
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) { |
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
err := json.Unmarshal([]byte(out), &containers) |
39 |
- assert.Assert(c, err == nil, fmt.Sprintf("Error inspecting the container: %s", err)) |
|
39 |
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err) |
|
40 | 40 |
assert.Equal(c, len(containers), 1) |
41 | 41 |
|
42 | 42 |
cont := containers[0] |
... | ... |
@@ -95,12 +95,12 @@ func (s *DockerSuite) TestCreateHostConfig(c *testing.T) { |
95 | 95 |
} |
96 | 96 |
|
97 | 97 |
err := json.Unmarshal([]byte(out), &containers) |
98 |
- assert.Assert(c, err == nil, fmt.Sprintf("Error inspecting the container: %s", err)) |
|
98 |
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err) |
|
99 | 99 |
assert.Equal(c, len(containers), 1) |
100 | 100 |
|
101 | 101 |
cont := containers[0] |
102 |
- assert.Assert(c, cont.HostConfig != nil, fmt.Sprintf("Expected HostConfig, got none")) |
|
103 |
- assert.Assert(c, cont.HostConfig.PublishAllPorts, fmt.Sprintf("Expected PublishAllPorts, got false")) |
|
102 |
+ assert.Assert(c, cont.HostConfig != nil, "Expected HostConfig, got none") |
|
103 |
+ assert.Assert(c, cont.HostConfig.PublishAllPorts, "Expected PublishAllPorts, got false") |
|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) { |
... | ... |
@@ -116,12 +116,12 @@ func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) { |
116 | 116 |
} |
117 | 117 |
} |
118 | 118 |
err := json.Unmarshal([]byte(out), &containers) |
119 |
- assert.Assert(c, err == nil, fmt.Sprintf("Error inspecting the container: %s", err)) |
|
119 |
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err) |
|
120 | 120 |
assert.Equal(c, len(containers), 1) |
121 | 121 |
|
122 | 122 |
cont := containers[0] |
123 | 123 |
|
124 |
- assert.Assert(c, cont.HostConfig != nil, fmt.Sprintf("Expected HostConfig, got none")) |
|
124 |
+ assert.Assert(c, cont.HostConfig != nil, "Expected HostConfig, got none") |
|
125 | 125 |
assert.Equal(c, len(cont.HostConfig.PortBindings), 4, fmt.Sprintf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings))) |
126 | 126 |
|
127 | 127 |
for k, v := range cont.HostConfig.PortBindings { |
... | ... |
@@ -146,11 +146,11 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) { |
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
err := json.Unmarshal([]byte(out), &containers) |
149 |
- assert.Assert(c, err == nil, fmt.Sprintf("Error inspecting the container: %s", err)) |
|
149 |
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err) |
|
150 | 150 |
assert.Equal(c, len(containers), 1) |
151 | 151 |
|
152 | 152 |
cont := containers[0] |
153 |
- assert.Assert(c, cont.HostConfig != nil, fmt.Sprintf("Expected HostConfig, got none")) |
|
153 |
+ assert.Assert(c, cont.HostConfig != nil, "Expected HostConfig, got none") |
|
154 | 154 |
assert.Equal(c, len(cont.HostConfig.PortBindings), 65535) |
155 | 155 |
|
156 | 156 |
for k, v := range cont.HostConfig.PortBindings { |
... | ... |
@@ -178,7 +178,7 @@ func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) { |
178 | 178 |
dockerCmd(c, "create", "--name", name, "-v", prefix+slash+"foo", "busybox") |
179 | 179 |
|
180 | 180 |
dir, err := inspectMountSourceField(name, prefix+slash+"foo") |
181 |
- assert.Assert(c, err == nil, fmt.Sprintf("Error getting volume host path: %q", err)) |
|
181 |
+ assert.Assert(c, err == nil, "Error getting volume host path: %q", err) |
|
182 | 182 |
|
183 | 183 |
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) { |
184 | 184 |
c.Fatalf("Volume was not created") |
... | ... |
@@ -131,7 +131,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *testing.T) { |
131 | 131 |
var format string |
132 | 132 |
for name, shouldRun := range m { |
133 | 133 |
out, err := s.d.Cmd("ps") |
134 |
- assert.Assert(c, err == nil, fmt.Sprintf("run ps: %v", out)) |
|
134 |
+ assert.Assert(c, err == nil, "run ps: %v", out) |
|
135 | 135 |
if shouldRun { |
136 | 136 |
format = "%scontainer %q is not running" |
137 | 137 |
} else { |
... | ... |
@@ -217,7 +217,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *testing.T) { |
217 | 217 |
|
218 | 218 |
if newBasesizeBytes < oldBasesizeBytes { |
219 | 219 |
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) |
220 |
- assert.Assert(c, err != nil, fmt.Sprintf("daemon should not have started as new base device size is less than existing base device size: %v", err)) |
|
220 |
+ assert.Assert(c, err != nil, "daemon should not have started as new base device size is less than existing base device size: %v", err) |
|
221 | 221 |
// 'err != nil' is expected behaviour, no new daemon started, |
222 | 222 |
// so no need to stop daemon. |
223 | 223 |
if err != nil { |
... | ... |
@@ -241,11 +241,11 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T) |
241 | 241 |
} |
242 | 242 |
|
243 | 243 |
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) |
244 |
- assert.Assert(c, err == nil, fmt.Sprintf("we should have been able to start the daemon with increased base device size: %v", err)) |
|
244 |
+ assert.Assert(c, err == nil, "we should have been able to start the daemon with increased base device size: %v", err) |
|
245 | 245 |
|
246 | 246 |
basesizeAfterRestart := getBaseDeviceSize(c, s.d) |
247 | 247 |
newBasesize, err := convertBasesize(newBasesizeBytes) |
248 |
- assert.Assert(c, err == nil, fmt.Sprintf("Error in converting base device size: %v", err)) |
|
248 |
+ assert.Assert(c, err == nil, "Error in converting base device size: %v", err) |
|
249 | 249 |
assert.Equal(c, newBasesize, basesizeAfterRestart, "Basesize passed is not equal to Basesize set") |
250 | 250 |
s.d.Stop(c) |
251 | 251 |
} |
... | ... |
@@ -1750,7 +1750,7 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T |
1750 | 1750 |
break |
1751 | 1751 |
} |
1752 | 1752 |
ip, err := s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.IPAddress}}'", contName) |
1753 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", ip)) |
|
1753 |
+ assert.Assert(c, err == nil, "%s", ip) |
|
1754 | 1754 |
|
1755 | 1755 |
assert.Assert(c, ip != bridgeIP) |
1756 | 1756 |
cont++ |
... | ... |
@@ -1780,7 +1780,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) { |
1780 | 1780 |
|
1781 | 1781 |
// pull a repository large enough to overfill the mounted filesystem |
1782 | 1782 |
pullOut, err := s.d.Cmd("pull", "debian:stretch") |
1783 |
- assert.Assert(c, err != nil, fmt.Sprintf("%s", pullOut)) |
|
1783 |
+ assert.Assert(c, err != nil, "%s", pullOut) |
|
1784 | 1784 |
assert.Assert(c, strings.Contains(pullOut, "no space left on device")) |
1785 | 1785 |
} |
1786 | 1786 |
|
... | ... |
@@ -1855,7 +1855,7 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) { |
1855 | 1855 |
out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup") |
1856 | 1856 |
assert.NilError(c, err) |
1857 | 1857 |
cgroupPaths := ParseCgroupPaths(string(out)) |
1858 |
- assert.Assert(c, len(cgroupPaths) != 0, fmt.Sprintf("unexpected output - %q", string(out))) |
|
1858 |
+ assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", string(out)) |
|
1859 | 1859 |
out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name) |
1860 | 1860 |
assert.NilError(c, err) |
1861 | 1861 |
id := strings.TrimSpace(string(out)) |
... | ... |
@@ -1867,7 +1867,7 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) { |
1867 | 1867 |
break |
1868 | 1868 |
} |
1869 | 1869 |
} |
1870 |
- assert.Assert(c, found, fmt.Sprintf("Cgroup path for container (%s) doesn't found in cgroups file: %s", expectedCgroup, cgroupPaths)) |
|
1870 |
+ assert.Assert(c, found, "Cgroup path for container (%s) doesn't found in cgroups file: %s", expectedCgroup, cgroupPaths) |
|
1871 | 1871 |
} |
1872 | 1872 |
|
1873 | 1873 |
func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *testing.T) { |
... | ... |
@@ -2007,7 +2007,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) { |
2007 | 2007 |
// the following check for mounts being cleared is pointless. |
2008 | 2008 |
skipMountCheck := false |
2009 | 2009 |
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo") |
2010 |
- assert.Assert(c, err == nil, fmt.Sprintf("Output: %s", mountOut)) |
|
2010 |
+ assert.Assert(c, err == nil, "Output: %s", mountOut) |
|
2011 | 2011 |
if !strings.Contains(string(mountOut), id) { |
2012 | 2012 |
skipMountCheck = true |
2013 | 2013 |
} |
... | ... |
@@ -2032,7 +2032,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) { |
2032 | 2032 |
} |
2033 | 2033 |
// Now, container mounts should be gone. |
2034 | 2034 |
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo") |
2035 |
- assert.Assert(c, err == nil, fmt.Sprintf("Output: %s", mountOut)) |
|
2035 |
+ assert.Assert(c, err == nil, "Output: %s", mountOut) |
|
2036 | 2036 |
comment := fmt.Sprintf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut) |
2037 | 2037 |
assert.Equal(c, strings.Contains(string(mountOut), id), false, comment) |
2038 | 2038 |
} |
... | ... |
@@ -2229,8 +2229,8 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T) |
2229 | 2229 |
out, err := s.d.Cmd("info") |
2230 | 2230 |
assert.NilError(c, err) |
2231 | 2231 |
|
2232 |
- assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: consul://consuladdr:consulport/some/path"))) |
|
2233 |
- assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: 192.168.56.100:0"))) |
|
2232 |
+ assert.Assert(c, strings.Contains(out, "Cluster Store: consul://consuladdr:consulport/some/path")) |
|
2233 |
+ assert.Assert(c, strings.Contains(out, "Cluster Advertise: 192.168.56.100:0")) |
|
2234 | 2234 |
} |
2235 | 2235 |
|
2236 | 2236 |
// Test for #21956 |
... | ... |
@@ -2376,11 +2376,11 @@ func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *testing.T) { |
2376 | 2376 |
|
2377 | 2377 |
expectedOutput := "nameserver 1.2.3.4" |
2378 | 2378 |
out, _ := s.d.Cmd("run", "--net=host", "busybox", "cat", "/etc/resolv.conf") |
2379 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
2379 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
2380 | 2380 |
expectedOutput = "search example.com" |
2381 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
2381 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
2382 | 2382 |
expectedOutput = "options timeout:3" |
2383 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
2383 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
2384 | 2384 |
} |
2385 | 2385 |
|
2386 | 2386 |
func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) { |
... | ... |
@@ -2555,10 +2555,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *testing. |
2555 | 2555 |
|
2556 | 2556 |
// top1 will exist after daemon restarts |
2557 | 2557 |
out, err := s.d.Cmd("run", "-d", "--name", "top1", "busybox:latest", "top") |
2558 |
- assert.Assert(c, err == nil, fmt.Sprintf("run top1: %v", out)) |
|
2558 |
+ assert.Assert(c, err == nil, "run top1: %v", out) |
|
2559 | 2559 |
// top2 will be removed after daemon restarts |
2560 | 2560 |
out, err = s.d.Cmd("run", "-d", "--rm", "--name", "top2", "busybox:latest", "top") |
2561 |
- assert.Assert(c, err == nil, fmt.Sprintf("run top2: %v", out)) |
|
2561 |
+ assert.Assert(c, err == nil, "run top2: %v", out) |
|
2562 | 2562 |
|
2563 | 2563 |
out, err = s.d.Cmd("ps") |
2564 | 2564 |
assert.NilError(c, err) |
... | ... |
@@ -2714,13 +2714,13 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) { |
2714 | 2714 |
|
2715 | 2715 |
out1, err := s.d.Cmd("exec", "-u", "test", "top", "id") |
2716 | 2716 |
// uid=100(test) gid=101(test) groups=101(test) |
2717 |
- assert.Assert(c, err == nil, fmt.Sprintf("Output: %s", out1)) |
|
2717 |
+ assert.Assert(c, err == nil, "Output: %s", out1) |
|
2718 | 2718 |
|
2719 | 2719 |
// restart daemon. |
2720 | 2720 |
s.d.Restart(c, "--live-restore") |
2721 | 2721 |
|
2722 | 2722 |
out2, err := s.d.Cmd("exec", "-u", "test", "top", "id") |
2723 |
- assert.Assert(c, err == nil, fmt.Sprintf("Output: %s", out2)) |
|
2723 |
+ assert.Assert(c, err == nil, "Output: %s", out2) |
|
2724 | 2724 |
assert.Equal(c, out2, out1, fmt.Sprintf("Output: before restart '%s', after restart '%s'", out1, out2)) |
2725 | 2725 |
|
2726 | 2726 |
out, err = s.d.Cmd("stop", "top") |
... | ... |
@@ -2773,7 +2773,7 @@ func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *testing.T) { |
2773 | 2773 |
StartedAt time.Time |
2774 | 2774 |
} |
2775 | 2775 |
out, err = s.d.Cmd("inspect", "-f", "{{json .State}}", id) |
2776 |
- assert.Assert(c, err == nil, fmt.Sprintf("output: %s", out)) |
|
2776 |
+ assert.Assert(c, err == nil, "output: %s", out) |
|
2777 | 2777 |
|
2778 | 2778 |
var origState state |
2779 | 2779 |
err = json.Unmarshal([]byte(strings.TrimSpace(out)), &origState) |
... | ... |
@@ -2799,7 +2799,7 @@ func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *testing.T) { |
2799 | 2799 |
} |
2800 | 2800 |
|
2801 | 2801 |
out, err := s.d.Cmd("inspect", "-f", "{{json .State}}", id) |
2802 |
- assert.Assert(c, err == nil, fmt.Sprintf("output: %s", out)) |
|
2802 |
+ assert.Assert(c, err == nil, "output: %s", out) |
|
2803 | 2803 |
|
2804 | 2804 |
var newState state |
2805 | 2805 |
err = json.Unmarshal([]byte(strings.TrimSpace(out)), &newState) |
... | ... |
@@ -297,7 +297,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *testing.T) |
297 | 297 |
p := hostVolumePath("external-volume-test") |
298 | 298 |
_, err = os.Lstat(p) |
299 | 299 |
assert.ErrorContains(c, err, "") |
300 |
- assert.Assert(c, os.IsNotExist(err), fmt.Sprintf("Expected volume path in host to not exist: %s, %v\n", p, err)) |
|
300 |
+ assert.Assert(c, os.IsNotExist(err), "Expected volume path in host to not exist: %s, %v\n", p, err) |
|
301 | 301 |
|
302 | 302 |
assert.Equal(c, s.ec.activations, 1) |
303 | 303 |
assert.Equal(c, s.ec.creations, 1) |
... | ... |
@@ -98,7 +98,7 @@ func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) { |
98 | 98 |
sizeString := lines[i][startIndex:endIndex] |
99 | 99 |
|
100 | 100 |
_, err := strconv.Atoi(strings.TrimSpace(sizeString)) |
101 |
- assert.Assert(c, err == nil, fmt.Sprintf("The size '%s' was not an Integer", sizeString)) |
|
101 |
+ assert.Assert(c, err == nil, "The size '%s' was not an Integer", sizeString) |
|
102 | 102 |
} |
103 | 103 |
} |
104 | 104 |
|
... | ... |
@@ -52,7 +52,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) { |
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
for _, linePrefix := range stringsToCheck { |
55 |
- assert.Assert(c, strings.Contains(out, linePrefix), fmt.Sprintf("couldn't find string %v in output", linePrefix)) |
|
55 |
+ assert.Assert(c, strings.Contains(out, linePrefix), "couldn't find string %v in output", linePrefix) |
|
56 | 56 |
} |
57 | 57 |
} |
58 | 58 |
|
... | ... |
@@ -118,7 +118,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) { |
118 | 118 |
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") |
119 | 119 |
|
120 | 120 |
out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox") |
121 |
- assert.Assert(c, err != nil, fmt.Sprintf("%d", exitCode)) |
|
121 |
+ assert.Assert(c, err != nil, "%d", exitCode) |
|
122 | 122 |
assert.Equal(c, exitCode, 1, fmt.Sprintf("%s", err)) |
123 | 123 |
assert.Assert(c, strings.Contains(out, "not a valid value for --type")) |
124 | 124 |
} |
... | ... |
@@ -129,7 +129,7 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) { |
129 | 129 |
out := inspectField(c, imageTest, "Size") |
130 | 130 |
|
131 | 131 |
size, err := strconv.Atoi(out) |
132 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to inspect size of the image: %s, %v", out, err)) |
|
132 |
+ assert.Assert(c, err == nil, "failed to inspect size of the image: %s, %v", out, err) |
|
133 | 133 |
|
134 | 134 |
//now see if the size turns out to be the same |
135 | 135 |
formatStr := fmt.Sprintf("--format={{eq .Size %d}}", size) |
... | ... |
@@ -151,7 +151,7 @@ func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) { |
151 | 151 |
out = inspectField(c, id, "State.ExitCode") |
152 | 152 |
|
153 | 153 |
exitCode, err := strconv.Atoi(out) |
154 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to inspect exitcode of the container: %s, %v", out, err)) |
|
154 |
+ assert.Assert(c, err == nil, "failed to inspect exitcode of the container: %s, %v", out, err) |
|
155 | 155 |
|
156 | 156 |
//now get the exit code to verify |
157 | 157 |
formatStr := fmt.Sprintf("--format={{eq .State.ExitCode %d}}", exitCode) |
... | ... |
@@ -171,12 +171,12 @@ func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) { |
171 | 171 |
deviceID := inspectField(c, imageTest, "GraphDriver.Data.DeviceId") |
172 | 172 |
|
173 | 173 |
_, err := strconv.Atoi(deviceID) |
174 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to inspect DeviceId of the image: %s, %v", deviceID, err)) |
|
174 |
+ assert.Assert(c, err == nil, "failed to inspect DeviceId of the image: %s, %v", deviceID, err) |
|
175 | 175 |
|
176 | 176 |
deviceSize := inspectField(c, imageTest, "GraphDriver.Data.DeviceSize") |
177 | 177 |
|
178 | 178 |
_, err = strconv.ParseUint(deviceSize, 10, 64) |
179 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err)) |
|
179 |
+ assert.Assert(c, err == nil, "failed to inspect DeviceSize of the image: %s, %v", deviceSize, err) |
|
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) { |
... | ... |
@@ -196,12 +196,12 @@ func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) { |
196 | 196 |
assert.Assert(c, imageDeviceID != deviceID) |
197 | 197 |
|
198 | 198 |
_, err := strconv.Atoi(deviceID) |
199 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to inspect DeviceId of the image: %s, %v", deviceID, err)) |
|
199 |
+ assert.Assert(c, err == nil, "failed to inspect DeviceId of the image: %s, %v", deviceID, err) |
|
200 | 200 |
|
201 | 201 |
deviceSize := inspectField(c, out, "GraphDriver.Data.DeviceSize") |
202 | 202 |
|
203 | 203 |
_, err = strconv.ParseUint(deviceSize, 10, 64) |
204 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err)) |
|
204 |
+ assert.Assert(c, err == nil, "failed to inspect DeviceSize of the image: %s, %v", deviceSize, err) |
|
205 | 205 |
} |
206 | 206 |
|
207 | 207 |
func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) { |
... | ... |
@@ -288,7 +288,7 @@ func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) { |
288 | 288 |
out := inspectFieldJSON(c, "test", "HostConfig.LogConfig") |
289 | 289 |
|
290 | 290 |
err := json.NewDecoder(strings.NewReader(out)).Decode(&logConfig) |
291 |
- assert.Assert(c, err == nil, fmt.Sprintf("%v", out)) |
|
291 |
+ assert.Assert(c, err == nil, "%v", out) |
|
292 | 292 |
|
293 | 293 |
assert.Equal(c, logConfig.Type, "json-file") |
294 | 294 |
assert.Equal(c, logConfig.Config["max-file"], "42", fmt.Sprintf("%v", logConfig)) |
... | ... |
@@ -27,7 +27,7 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *testing.T) { |
27 | 27 |
out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true") |
28 | 28 |
|
29 | 29 |
// an invalid container target should produce an error |
30 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
30 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
31 | 31 |
// an invalid container target should produce an error |
32 | 32 |
// note: convert the output to lowercase first as the error string |
33 | 33 |
// capitalization was changed after API version 1.32 |
... | ... |
@@ -169,7 +169,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) { |
169 | 169 |
getIP := func(hosts []byte, hostname string) string { |
170 | 170 |
re := regexp.MustCompile(fmt.Sprintf(`(\S*)\t%s`, regexp.QuoteMeta(hostname))) |
171 | 171 |
matches := re.FindSubmatch(hosts) |
172 |
- assert.Assert(c, matches != nil, fmt.Sprintf("Hostname %s have no matches in hosts", hostname)) |
|
172 |
+ assert.Assert(c, matches != nil, "Hostname %s have no matches in hosts", hostname) |
|
173 | 173 |
return string(matches[1]) |
174 | 174 |
} |
175 | 175 |
ip := getIP(content, "one") |
... | ... |
@@ -220,7 +220,7 @@ func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) { |
220 | 220 |
out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true") |
221 | 221 |
|
222 | 222 |
// Running container linking to a container with --net host should have failed |
223 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
223 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
224 | 224 |
// Running container linking to a container with --net host should have failed |
225 | 225 |
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error())) |
226 | 226 |
} |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
package main |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
5 | 4 |
"strings" |
6 | 5 |
"testing" |
7 | 6 |
|
... | ... |
@@ -20,7 +19,7 @@ const stringCheckPS = "PID USER" |
20 | 20 |
// stop the tests. |
21 | 21 |
func dockerCmdWithFail(c *testing.T, args ...string) (string, int) { |
22 | 22 |
out, status, err := dockerCmdWithError(args...) |
23 |
- assert.Assert(c, err != nil, fmt.Sprintf("%v", out)) |
|
23 |
+ assert.Assert(c, err != nil, "%v", out) |
|
24 | 24 |
return out, status |
25 | 25 |
} |
26 | 26 |
|
... | ... |
@@ -403,7 +403,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) { |
403 | 403 |
// contains active container, its deletion should fail. |
404 | 404 |
out, _, err := dockerCmdWithError("network", "rm", "testDelMulti0", "testDelMulti1", "testDelMulti2") |
405 | 405 |
// err should not be nil due to deleting testDelMulti2 failed. |
406 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
406 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
407 | 407 |
// testDelMulti2 should fail due to network has active endpoints |
408 | 408 |
assert.Assert(c, strings.Contains(out, "has active endpoints")) |
409 | 409 |
assertNwNotAvailable(c, "testDelMulti0") |
... | ... |
@@ -1298,7 +1298,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) { |
1298 | 1298 |
|
1299 | 1299 |
// Still it should fail to connect to the default network with a specified IP (whatever ip) |
1300 | 1300 |
out, _, err := dockerCmdWithError("network", "connect", "--ip", "172.21.55.44", "bridge", "c0") |
1301 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
1301 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
1302 | 1302 |
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error())) |
1303 | 1303 |
} |
1304 | 1304 |
|
... | ... |
@@ -1336,10 +1336,10 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T |
1336 | 1336 |
assertNwIsAvailable(c, "n0") |
1337 | 1337 |
|
1338 | 1338 |
out, _, err := dockerCmdWithError("run", "-d", "--ip", "172.28.99.88", "--net", "n0", "busybox", "top") |
1339 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
1339 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
1340 | 1340 |
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())) |
1341 | 1341 |
out, _, err = dockerCmdWithError("run", "-d", "--ip6", "2001:db8:1234::9988", "--net", "n0", "busybox", "top") |
1342 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
1342 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
1343 | 1343 |
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())) |
1344 | 1344 |
dockerCmd(c, "network", "rm", "n0") |
1345 | 1345 |
assertNwNotAvailable(c, "n0") |
... | ... |
@@ -1347,7 +1347,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T |
1347 | 1347 |
|
1348 | 1348 |
func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) { |
1349 | 1349 |
out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top") |
1350 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
1350 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
1351 | 1351 |
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error())) |
1352 | 1352 |
} |
1353 | 1353 |
|
... | ... |
@@ -1474,8 +1474,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *testing.T) { |
1474 | 1474 |
dockerCmd(c, "start", containerName) |
1475 | 1475 |
assert.Assert(c, waitRun(containerName) == nil) |
1476 | 1476 |
networks := inspectField(c, containerName, "NetworkSettings.Networks") |
1477 |
- assert.Assert(c, strings.Contains(networks, netWorkName1), fmt.Sprintf(fmt.Sprintf("Should contain '%s' network", netWorkName1))) |
|
1478 |
- assert.Assert(c, strings.Contains(networks, netWorkName2), fmt.Sprintf(fmt.Sprintf("Should contain '%s' network", netWorkName2))) |
|
1477 |
+ assert.Assert(c, strings.Contains(networks, netWorkName1), fmt.Sprintf("Should contain '%s' network", netWorkName1)) |
|
1478 |
+ assert.Assert(c, strings.Contains(networks, netWorkName2), fmt.Sprintf("Should contain '%s' network", netWorkName2)) |
|
1479 | 1479 |
assert.Assert(c, !strings.Contains(networks, "bridge"), "Should not contain 'bridge' network") |
1480 | 1480 |
} |
1481 | 1481 |
|
... | ... |
@@ -1538,11 +1538,11 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) |
1538 | 1538 |
|
1539 | 1539 |
// verify the alias option is rejected when running on predefined network |
1540 | 1540 |
out, _, err := dockerCmdWithError("run", "--rm", "--name=any", "--net-alias=any", "busybox:glibc", "top") |
1541 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
1541 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
1542 | 1542 |
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error())) |
1543 | 1543 |
// verify the alias option is rejected when connecting to predefined network |
1544 | 1544 |
out, _, err = dockerCmdWithError("network", "connect", "--alias=any", "bridge", "first") |
1545 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
1545 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
1546 | 1546 |
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error())) |
1547 | 1547 |
} |
1548 | 1548 |
|
... | ... |
@@ -428,7 +428,7 @@ func (s *DockerSuite) TestPluginUpgrade(c *testing.T) { |
428 | 428 |
|
429 | 429 |
// make sure "v2" does not exists |
430 | 430 |
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id, "rootfs", "v2")) |
431 |
- assert.Assert(c, os.IsNotExist(err), fmt.Sprintf("%s", out)) |
|
431 |
+ assert.Assert(c, os.IsNotExist(err), "%s", out) |
|
432 | 432 |
|
433 | 433 |
dockerCmd(c, "plugin", "disable", "-f", plugin) |
434 | 434 |
dockerCmd(c, "plugin", "upgrade", "--grant-all-permissions", "--skip-remote-check", plugin, pluginV2) |
... | ... |
@@ -104,7 +104,7 @@ func (s *DockerSuite) TestPortList(c *testing.T) { |
104 | 104 |
"-p", "9090-9092:80", |
105 | 105 |
"busybox", "top") |
106 | 106 |
// Exhausted port range did not return an error |
107 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
107 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
108 | 108 |
|
109 | 109 |
for i := 0; i < 3; i++ { |
110 | 110 |
dockerCmd(c, "rm", "-f", IDs[i]) |
... | ... |
@@ -120,7 +120,7 @@ func (s *DockerSuite) TestPortList(c *testing.T) { |
120 | 120 |
"-p", invalidRange, |
121 | 121 |
"busybox", "top") |
122 | 122 |
// Port range should have returned an error |
123 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
123 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
// test host range:container range spec. |
... | ... |
@@ -299,7 +299,7 @@ func (s *DockerSuite) TestPortHostBinding(c *testing.T) { |
299 | 299 |
|
300 | 300 |
out, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "9876") |
301 | 301 |
// Port is still bound after the Container is removed |
302 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
302 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
303 | 303 |
} |
304 | 304 |
|
305 | 305 |
func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) { |
... | ... |
@@ -311,7 +311,7 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) { |
311 | 311 |
out, _ = dockerCmd(c, "port", firstID, "80") |
312 | 312 |
|
313 | 313 |
_, exposedPort, err := net.SplitHostPort(out) |
314 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %s", out)) |
|
314 |
+ assert.Assert(c, err == nil, "out: %s", out) |
|
315 | 315 |
|
316 | 316 |
dockerCmd(c, "run", "--net=host", "busybox", |
317 | 317 |
"nc", "localhost", strings.TrimSpace(exposedPort)) |
... | ... |
@@ -321,7 +321,7 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) { |
321 | 321 |
out, _, err = dockerCmdWithError("run", "--net=host", "busybox", |
322 | 322 |
"nc", "localhost", strings.TrimSpace(exposedPort)) |
323 | 323 |
// Port is still bound after the Container is removed |
324 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
324 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
325 | 325 |
} |
326 | 326 |
|
327 | 327 |
func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) { |
... | ... |
@@ -175,7 +175,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *testing.T) { |
175 | 175 |
assert.Equal(c, foundID, id[:12], fmt.Sprintf("Expected id %s, got %s", id[:12], foundID)) |
176 | 176 |
expectedSize := fmt.Sprintf("%dB", 2+baseBytes) |
177 | 177 |
foundSize := lines[1][sizeIndex:] |
178 |
- assert.Assert(c, strings.Contains(foundSize, expectedSize), fmt.Sprintf("Expected size %q, got %q", expectedSize, foundSize)) |
|
178 |
+ assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize) |
|
179 | 179 |
} |
180 | 180 |
|
181 | 181 |
func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) { |
... | ... |
@@ -442,11 +442,11 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) { |
442 | 442 |
secondZero, _ := dockerCmd(c, "run", "-d", "busybox", "true") |
443 | 443 |
|
444 | 444 |
out, _, err := dockerCmdWithError("run", "--name", "nonzero1", "busybox", "false") |
445 |
- assert.Assert(c, err != nil, fmt.Sprintf("Should fail. out: %s", out)) |
|
445 |
+ assert.Assert(c, err != nil, "Should fail. out: %s", out) |
|
446 | 446 |
firstNonZero := getIDByName(c, "nonzero1") |
447 | 447 |
|
448 | 448 |
out, _, err = dockerCmdWithError("run", "--name", "nonzero2", "busybox", "false") |
449 |
- assert.Assert(c, err != nil, fmt.Sprintf("Should fail. out: %s", out)) |
|
449 |
+ assert.Assert(c, err != nil, "Should fail. out: %s", out) |
|
450 | 450 |
secondNonZero := getIDByName(c, "nonzero2") |
451 | 451 |
|
452 | 452 |
// filter containers by exited=0 |
... | ... |
@@ -516,7 +516,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) { |
516 | 516 |
|
517 | 517 |
// Make sure it DOESN'T show up w/o a '-a' for normal 'ps' |
518 | 518 |
out, _ = dockerCmd(c, "ps", "-q") |
519 |
- assert.Assert(c, !strings.Contains(out, shortCID), fmt.Sprintf("Should have not seen '%s' in ps output:\n%s", shortCID, out)) |
|
519 |
+ assert.Assert(c, !strings.Contains(out, shortCID), "Should have not seen '%s' in ps output:\n%s", shortCID, out) |
|
520 | 520 |
// Make sure it DOES show up as 'Created' for 'ps -a' |
521 | 521 |
out, _ = dockerCmd(c, "ps", "-a") |
522 | 522 |
|
... | ... |
@@ -526,7 +526,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) { |
526 | 526 |
continue |
527 | 527 |
} |
528 | 528 |
hits++ |
529 |
- assert.Assert(c, strings.Contains(line, "Created"), fmt.Sprintf("Missing 'Created' on '%s'", line)) |
|
529 |
+ assert.Assert(c, strings.Contains(line, "Created"), "Missing 'Created' on '%s'", line) |
|
530 | 530 |
} |
531 | 531 |
|
532 | 532 |
assert.Equal(c, hits, 1, fmt.Sprintf("Should have seen '%s' in ps -a output once:%d\n%s", shortCID, hits, out)) |
... | ... |
@@ -602,7 +602,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) { |
602 | 602 |
out, _ = dockerCmd(c, "ps", "-l") |
603 | 603 |
lines = strings.Split(strings.TrimSpace(string(out)), "\n") |
604 | 604 |
fields = strings.Fields(lines[1]) |
605 |
- assert.Assert(c, fields[len(fields)-2] != expected, fmt.Sprintf("Should not got %v", expected)) |
|
605 |
+ assert.Assert(c, fields[len(fields)-2] != expected, "Should not got %v", expected) |
|
606 | 606 |
} |
607 | 607 |
|
608 | 608 |
func (s *DockerSuite) TestPsShowMounts(c *testing.T) { |
... | ... |
@@ -26,7 +26,7 @@ func (s *DockerSuite) TestRmiWithContainerFails(c *testing.T) { |
26 | 26 |
// Container is using image, should not be able to rmi |
27 | 27 |
assert.ErrorContains(c, err, "") |
28 | 28 |
// Container is using image, error message should contain errSubstr |
29 |
- assert.Assert(c, strings.Contains(out, errSubstr), fmt.Sprintf("Container: %q", cleanedContainerID)) |
|
29 |
+ assert.Assert(c, strings.Contains(out, errSubstr), "Container: %q", cleanedContainerID) |
|
30 | 30 |
// make sure it didn't delete the busybox name |
31 | 31 |
images, _ := dockerCmd(c, "images") |
32 | 32 |
// The name 'busybox' should not have been removed from images |
... | ... |
@@ -99,7 +99,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *testing.T) { |
99 | 99 |
|
100 | 100 |
imagesAfter = cli.DockerCmd(c, "images", "-a").Combined() |
101 | 101 |
// rmi -f failed, image still exists |
102 |
- assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]), fmt.Sprintf("ImageID:%q; ImagesAfter: %q", imgID, imagesAfter)) |
|
102 |
+ assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]), "ImageID:%q; ImagesAfter: %q", imgID, imagesAfter) |
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) { |
... | ... |
@@ -209,7 +209,7 @@ func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) { |
209 | 209 |
assert.Assert(c, !strings.Contains(out, "Untagged: "+tag1)) |
210 | 210 |
// Check built image still exists |
211 | 211 |
images, _ := dockerCmd(c, "images", "-a") |
212 |
- assert.Assert(c, strings.Contains(images, imageName), fmt.Sprintf("Built image missing %q; Images: %q", imageName, images)) |
|
212 |
+ assert.Assert(c, strings.Contains(images, imageName), "Built image missing %q; Images: %q", imageName, images) |
|
213 | 213 |
} |
214 | 214 |
|
215 | 215 |
func (s *DockerSuite) TestRmiBlank(c *testing.T) { |
... | ... |
@@ -217,9 +217,9 @@ func (s *DockerSuite) TestRmiBlank(c *testing.T) { |
217 | 217 |
// Should have failed to delete ' ' image |
218 | 218 |
assert.ErrorContains(c, err, "") |
219 | 219 |
// Wrong error message generated |
220 |
- assert.Assert(c, !strings.Contains(out, "no such id"), fmt.Sprintf("out: %s", out)) |
|
220 |
+ assert.Assert(c, !strings.Contains(out, "no such id"), "out: %s", out) |
|
221 | 221 |
// Expected error message not generated |
222 |
- assert.Assert(c, strings.Contains(out, "image name cannot be blank"), fmt.Sprintf("out: %s", out)) |
|
222 |
+ assert.Assert(c, strings.Contains(out, "image name cannot be blank"), "out: %s", out) |
|
223 | 223 |
} |
224 | 224 |
|
225 | 225 |
func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) { |
... | ... |
@@ -244,7 +244,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) { |
244 | 244 |
out, _, err := dockerCmdWithError("rmi", "-f", imageIds[0]) |
245 | 245 |
// The image of the running container should not be removed. |
246 | 246 |
assert.ErrorContains(c, err, "") |
247 |
- assert.Assert(c, strings.Contains(out, "image is being used by running container"), fmt.Sprintf("out: %s", out)) |
|
247 |
+ assert.Assert(c, strings.Contains(out, "image is being used by running container"), "out: %s", out) |
|
248 | 248 |
} |
249 | 249 |
|
250 | 250 |
// #13422 |
... | ... |
@@ -3208,7 +3208,7 @@ func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) { |
3208 | 3208 |
assert.Assert(c, err != nil, "Expected docker run to fail!") |
3209 | 3209 |
|
3210 | 3210 |
containerID, err := inspectFieldWithError(name, "Id") |
3211 |
- assert.Assert(c, err != nil, fmt.Sprintf("Expected not to have this container: %s!", containerID)) |
|
3211 |
+ assert.Assert(c, err != nil, "Expected not to have this container: %s!", containerID) |
|
3212 | 3212 |
assert.Equal(c, containerID, "", fmt.Sprintf("Expected not to have this container: %s!", containerID)) |
3213 | 3213 |
} |
3214 | 3214 |
|
... | ... |
@@ -3944,7 +3944,7 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) { |
3944 | 3944 |
// We will need the following `inspect` to diagnose the issue if test fails (#21247) |
3945 | 3945 |
out1, err1 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "test") |
3946 | 3946 |
out2, err2 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "fail") |
3947 |
- assert.Assert(c, err != nil, fmt.Sprintf("Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2)) |
|
3947 |
+ assert.Assert(c, err != nil, "Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2) |
|
3948 | 3948 |
// check for windows error as well |
3949 | 3949 |
// TODO Windows Post TP5. Fix the error message string |
3950 | 3950 |
assert.Assert(c, strings.Contains(string(out), "port is already allocated") || |
... | ... |
@@ -4030,9 +4030,9 @@ func (s *DockerSuite) TestRunDNSInHostMode(c *testing.T) { |
4030 | 4030 |
expectedOutput2 := "search example.com" |
4031 | 4031 |
expectedOutput3 := "options timeout:3" |
4032 | 4032 |
out := cli.DockerCmd(c, "run", "--dns=1.2.3.4", "--dns-search=example.com", "--dns-opt=timeout:3", "--net=host", "busybox", "cat", "/etc/resolv.conf").Combined() |
4033 |
- assert.Assert(c, strings.Contains(out, expectedOutput1), fmt.Sprintf("Expected '%s', but got %q", expectedOutput1, out)) |
|
4034 |
- assert.Assert(c, strings.Contains(out, expectedOutput2), fmt.Sprintf("Expected '%s', but got %q", expectedOutput2, out)) |
|
4035 |
- assert.Assert(c, strings.Contains(out, expectedOutput3), fmt.Sprintf("Expected '%s', but got %q", expectedOutput3, out)) |
|
4033 |
+ assert.Assert(c, strings.Contains(out, expectedOutput1), "Expected '%s', but got %q", expectedOutput1, out) |
|
4034 |
+ assert.Assert(c, strings.Contains(out, expectedOutput2), "Expected '%s', but got %q", expectedOutput2, out) |
|
4035 |
+ assert.Assert(c, strings.Contains(out, expectedOutput3), "Expected '%s', but got %q", expectedOutput3, out) |
|
4036 | 4036 |
} |
4037 | 4037 |
|
4038 | 4038 |
// Test case for #21976 |
... | ... |
@@ -4041,14 +4041,14 @@ func (s *DockerSuite) TestRunAddHostInHostMode(c *testing.T) { |
4041 | 4041 |
|
4042 | 4042 |
expectedOutput := "1.2.3.4\textra" |
4043 | 4043 |
out, _ := dockerCmd(c, "run", "--add-host=extra:1.2.3.4", "--net=host", "busybox", "cat", "/etc/hosts") |
4044 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
4044 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
4045 | 4045 |
} |
4046 | 4046 |
|
4047 | 4047 |
func (s *DockerSuite) TestRunRmAndWait(c *testing.T) { |
4048 | 4048 |
dockerCmd(c, "run", "--name=test", "--rm", "-d", "busybox", "sh", "-c", "sleep 3;exit 2") |
4049 | 4049 |
|
4050 | 4050 |
out, code, err := dockerCmdWithError("wait", "test") |
4051 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %s; exit code: %d", out, code)) |
|
4051 |
+ assert.Assert(c, err == nil, "out: %s; exit code: %d", out, code) |
|
4052 | 4052 |
assert.Equal(c, out, "2\n", "exit code: %d", code) |
4053 | 4053 |
assert.Equal(c, code, 0) |
4054 | 4054 |
} |
... | ... |
@@ -4134,7 +4134,7 @@ func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) { |
4134 | 4134 |
|
4135 | 4135 |
out, _, err := dockerCmdWithError("run", "--name=fail", "--log-driver=splunk", "busybox", "true") |
4136 | 4136 |
assert.ErrorContains(c, err, "") |
4137 |
- assert.Assert(c, strings.Contains(out, "failed to initialize logging driver"), fmt.Sprintf("error should be about logging driver, got output %s", out)) |
|
4137 |
+ assert.Assert(c, strings.Contains(out, "failed to initialize logging driver"), "error should be about logging driver, got output %s", out) |
|
4138 | 4138 |
// NGoroutines is not updated right away, so we need to wait before failing |
4139 | 4139 |
assert.Assert(c, waitForGoroutines(nroutines) == nil) |
4140 | 4140 |
} |
... | ... |
@@ -4154,8 +4154,8 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) { |
4154 | 4154 |
} |
4155 | 4155 |
for _, attempt := range attempts { |
4156 | 4156 |
_, _, err := dockerCmdWithError("run", "--security-opt=credentialspec="+attempt.value, "busybox", "true") |
4157 |
- assert.Assert(c, err != nil, fmt.Sprintf("%s expected non-nil err", attempt.value)) |
|
4158 |
- assert.Assert(c, strings.Contains(err.Error(), attempt.expectedError), fmt.Sprintf("%s expected %s got %s", attempt.value, attempt.expectedError, err)) |
|
4157 |
+ assert.Assert(c, err != nil, "%s expected non-nil err", attempt.value) |
|
4158 |
+ assert.Assert(c, strings.Contains(err.Error(), attempt.expectedError), "%s expected %s got %s", attempt.value, attempt.expectedError, err) |
|
4159 | 4159 |
} |
4160 | 4160 |
} |
4161 | 4161 |
|
... | ... |
@@ -4486,11 +4486,11 @@ func (s *DockerSuite) TestRunMount(c *testing.T) { |
4486 | 4486 |
_, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName}, |
4487 | 4487 |
append(opts, []string{"busybox", "top"}...)...)...) |
4488 | 4488 |
if testCase.valid { |
4489 |
- assert.Assert(c, err == nil, fmt.Sprintf("got error while creating a container with %v (%s)", opts, cName)) |
|
4490 |
- assert.Assert(c, testCase.fn(cName) == nil, fmt.Sprintf("got error while executing test for %v (%s)", opts, cName)) |
|
4489 |
+ assert.Assert(c, err == nil, "got error while creating a container with %v (%s)", opts, cName) |
|
4490 |
+ assert.Assert(c, testCase.fn(cName) == nil, "got error while executing test for %v (%s)", opts, cName) |
|
4491 | 4491 |
dockerCmd(c, "rm", "-f", cName) |
4492 | 4492 |
} else { |
4493 |
- assert.Assert(c, err != nil, fmt.Sprintf("got nil while creating a container with %v (%s)", opts, cName)) |
|
4493 |
+ assert.Assert(c, err != nil, "got nil while creating a container with %v (%s)", opts, cName) |
|
4494 | 4494 |
} |
4495 | 4495 |
} |
4496 | 4496 |
} |
... | ... |
@@ -69,8 +69,8 @@ func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *testing.T) { |
69 | 69 |
|
70 | 70 |
// Create a temporary tmpfs mount. |
71 | 71 |
tmpfsDir := filepath.Join(tmpDir, "tmpfs") |
72 |
- assert.Assert(c, os.MkdirAll(tmpfsDir, 0777) == nil, fmt.Sprintf("failed to mkdir at %s", tmpfsDir)) |
|
73 |
- assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, fmt.Sprintf("failed to create a tmpfs mount at %s", tmpfsDir)) |
|
72 |
+ assert.Assert(c, os.MkdirAll(tmpfsDir, 0777) == nil, "failed to mkdir at %s", tmpfsDir) |
|
73 |
+ assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, "failed to create a tmpfs mount at %s", tmpfsDir) |
|
74 | 74 |
|
75 | 75 |
f, err := ioutil.TempFile(tmpfsDir, "touch-me") |
76 | 76 |
assert.NilError(c, err) |
... | ... |
@@ -671,10 +671,10 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *testing.T) { |
671 | 671 |
out, _, err := dockerCmdWithError("run", "--memory-swappiness", "101", "busybox", "true") |
672 | 672 |
assert.ErrorContains(c, err, "") |
673 | 673 |
expected := "Valid memory swappiness range is 0-100" |
674 |
- assert.Assert(c, strings.Contains(out, expected), fmt.Sprintf("Expected output to contain %q, not %q", out, expected)) |
|
674 |
+ assert.Assert(c, strings.Contains(out, expected), "Expected output to contain %q, not %q", out, expected) |
|
675 | 675 |
out, _, err = dockerCmdWithError("run", "--memory-swappiness", "-10", "busybox", "true") |
676 | 676 |
assert.ErrorContains(c, err, "") |
677 |
- assert.Assert(c, strings.Contains(out, expected), fmt.Sprintf("Expected output to contain %q, not %q", out, expected)) |
|
677 |
+ assert.Assert(c, strings.Contains(out, expected), "Expected output to contain %q, not %q", out, expected) |
|
678 | 678 |
} |
679 | 679 |
|
680 | 680 |
func (s *DockerSuite) TestRunWithMemoryReservation(c *testing.T) { |
... | ... |
@@ -136,13 +136,13 @@ func (s *DockerSuite) TestSaveImageId(c *testing.T) { |
136 | 136 |
|
137 | 137 |
var err error |
138 | 138 |
tarCmd.Stdin, err = saveCmd.StdoutPipe() |
139 |
- assert.Assert(c, err == nil, fmt.Sprintf("cannot set stdout pipe for tar: %v", err)) |
|
139 |
+ assert.Assert(c, err == nil, "cannot set stdout pipe for tar: %v", err) |
|
140 | 140 |
grepCmd := exec.Command("grep", cleanedLongImageID) |
141 | 141 |
grepCmd.Stdin, err = tarCmd.StdoutPipe() |
142 |
- assert.Assert(c, err == nil, fmt.Sprintf("cannot set stdout pipe for grep: %v", err)) |
|
142 |
+ assert.Assert(c, err == nil, "cannot set stdout pipe for grep: %v", err) |
|
143 | 143 |
|
144 |
- assert.Assert(c, tarCmd.Start() == nil, fmt.Sprintf("tar failed with error: %v", err)) |
|
145 |
- assert.Assert(c, saveCmd.Start() == nil, fmt.Sprintf("docker save failed with error: %v", err)) |
|
144 |
+ assert.Assert(c, tarCmd.Start() == nil, "tar failed with error: %v", err) |
|
145 |
+ assert.Assert(c, saveCmd.Start() == nil, "docker save failed with error: %v", err) |
|
146 | 146 |
defer func() { |
147 | 147 |
saveCmd.Wait() |
148 | 148 |
tarCmd.Wait() |
... | ... |
@@ -151,7 +151,7 @@ func (s *DockerSuite) TestSaveImageId(c *testing.T) { |
151 | 151 |
|
152 | 152 |
out, _, err = runCommandWithOutput(grepCmd) |
153 | 153 |
|
154 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to save repo with image ID: %s, %v", out, err)) |
|
154 |
+ assert.Assert(c, err == nil, "failed to save repo with image ID: %s, %v", out, err) |
|
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
// save a repo and try to load it using flags |
... | ... |
@@ -263,7 +263,7 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *testing.T) { |
263 | 263 |
|
264 | 264 |
name := "save-directory-permissions" |
265 | 265 |
tmpDir, err := ioutil.TempDir("", "save-layers-with-directories") |
266 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to create temporary directory: %s", err)) |
|
266 |
+ assert.Assert(c, err == nil, "failed to create temporary directory: %s", err) |
|
267 | 267 |
extractionDirectory := filepath.Join(tmpDir, "image-extraction-dir") |
268 | 268 |
os.Mkdir(extractionDirectory, 0777) |
269 | 269 |
|
... | ... |
@@ -76,7 +76,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *testing.T) { |
76 | 76 |
}, |
77 | 77 |
Data: []byte("TESTINGDATA"), |
78 | 78 |
}) |
79 |
- assert.Assert(c, id != "", fmt.Sprintf("secrets: %s", id)) |
|
79 |
+ assert.Assert(c, id != "", "secrets: %s", id) |
|
80 | 80 |
|
81 | 81 |
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--secret", testName, "busybox", "top") |
82 | 82 |
assert.NilError(c, err, out) |
... | ... |
@@ -118,7 +118,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testi |
118 | 118 |
}, |
119 | 119 |
Data: []byte("TESTINGDATA " + testName + " " + testTarget), |
120 | 120 |
}) |
121 |
- assert.Assert(c, id != "", fmt.Sprintf("secrets: %s", id)) |
|
121 |
+ assert.Assert(c, id != "", "secrets: %s", id) |
|
122 | 122 |
|
123 | 123 |
secretFlags = append(secretFlags, "--secret", fmt.Sprintf("source=%s,target=%s", testName, testTarget)) |
124 | 124 |
} |
... | ... |
@@ -174,7 +174,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing |
174 | 174 |
}, |
175 | 175 |
Data: []byte("TESTINGDATA"), |
176 | 176 |
}) |
177 |
- assert.Assert(c, id != "", fmt.Sprintf("secrets: %s", id)) |
|
177 |
+ assert.Assert(c, id != "", "secrets: %s", id) |
|
178 | 178 |
|
179 | 179 |
serviceName := "svc" |
180 | 180 |
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--secret", "source=mysecret,target=target1", "--secret", "source=mysecret,target=target2", "busybox", "top") |
... | ... |
@@ -224,7 +224,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *testing.T) { |
224 | 224 |
}, |
225 | 225 |
Data: []byte("TESTINGDATA"), |
226 | 226 |
}) |
227 |
- assert.Assert(c, id != "", fmt.Sprintf("configs: %s", id)) |
|
227 |
+ assert.Assert(c, id != "", "configs: %s", id) |
|
228 | 228 |
|
229 | 229 |
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--config", testName, "busybox", "top") |
230 | 230 |
assert.NilError(c, err, out) |
... | ... |
@@ -265,7 +265,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi |
265 | 265 |
}, |
266 | 266 |
Data: []byte("TESTINGDATA " + testName + " " + testTarget), |
267 | 267 |
}) |
268 |
- assert.Assert(c, id != "", fmt.Sprintf("configs: %s", id)) |
|
268 |
+ assert.Assert(c, id != "", "configs: %s", id) |
|
269 | 269 |
|
270 | 270 |
configFlags = append(configFlags, "--config", fmt.Sprintf("source=%s,target=%s", testName, testTarget)) |
271 | 271 |
} |
... | ... |
@@ -321,7 +321,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing |
321 | 321 |
}, |
322 | 322 |
Data: []byte("TESTINGDATA"), |
323 | 323 |
}) |
324 |
- assert.Assert(c, id != "", fmt.Sprintf("configs: %s", id)) |
|
324 |
+ assert.Assert(c, id != "", "configs: %s", id) |
|
325 | 325 |
|
326 | 326 |
serviceName := "svc" |
327 | 327 |
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--config", "source=myconfig,target=target1", "--config", "source=myconfig,target=target2", "busybox", "top") |
... | ... |
@@ -20,7 +20,7 @@ func (s *DockerSuite) TestStartAttachReturnsOnError(c *testing.T) { |
20 | 20 |
// Expect this to fail because the above container is stopped, this is what we want |
21 | 21 |
out, _, err := dockerCmdWithError("run", "--name", "test2", "--link", "test:test", "busybox") |
22 | 22 |
// err shouldn't be nil because container test2 try to link to stopped container |
23 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
23 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
24 | 24 |
|
25 | 25 |
ch := make(chan error) |
26 | 26 |
go func() { |
... | ... |
@@ -78,7 +78,7 @@ func (s *DockerSuite) TestStartRecordError(c *testing.T) { |
78 | 78 |
// Expect this to fail and records error because of ports conflict |
79 | 79 |
out, _, err := dockerCmdWithError("run", "-d", "--name", "test2", "-p", "9999:9999", "busybox", "top") |
80 | 80 |
// err shouldn't be nil because docker run will fail |
81 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
81 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
82 | 82 |
|
83 | 83 |
stateErr = inspectField(c, "test2", "State.Error") |
84 | 84 |
assert.Assert(c, strings.Contains(stateErr, "port is already allocated")) |
... | ... |
@@ -100,7 +100,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *testing.T) { |
100 | 100 |
|
101 | 101 |
out, _, err := dockerCmdWithError("start", "testing") |
102 | 102 |
// an error should have been shown that you cannot start paused container |
103 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
103 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
104 | 104 |
// an error should have been shown that you cannot start paused container |
105 | 105 |
assert.Assert(c, strings.Contains(strings.ToLower(out), "cannot start a paused container, try unpause instead")) |
106 | 106 |
} |
... | ... |
@@ -128,7 +128,7 @@ func (s *DockerSuite) TestStartMultipleContainers(c *testing.T) { |
128 | 128 |
expErr := "failed to start containers: [child_first]" |
129 | 129 |
out, _, err := dockerCmdWithError("start", "child_first", "parent", "child_second") |
130 | 130 |
// err shouldn't be nil because start will fail |
131 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
131 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
132 | 132 |
// output does not correspond to what was expected |
133 | 133 |
if !(strings.Contains(out, expOut) || strings.Contains(err.Error(), expErr)) { |
134 | 134 |
c.Fatalf("Expected out: %v with err: %v but got out: %v with err: %v", expOut, expErr, out, err) |
... | ... |
@@ -156,7 +156,7 @@ func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) { |
156 | 156 |
for _, option := range []string{"-a", "-i", "-ai"} { |
157 | 157 |
out, _, err := dockerCmdWithError("start", option, "test1", "test2", "test3") |
158 | 158 |
// err shouldn't be nil because start will fail |
159 |
- assert.Assert(c, err != nil, fmt.Sprintf("out: %s", out)) |
|
159 |
+ assert.Assert(c, err != nil, "out: %s", out) |
|
160 | 160 |
// output does not correspond to what was expected |
161 | 161 |
assert.Assert(c, strings.Contains(out, "you cannot start and attach multiple containers at once")) |
162 | 162 |
} |
... | ... |
@@ -171,7 +171,7 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *testing.T) { |
171 | 171 |
func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *testing.T) { |
172 | 172 |
d := s.AddDaemon(c, true, true) |
173 | 173 |
hostname, err := d.Cmd("node", "inspect", "--format", "{{.Description.Hostname}}", "self") |
174 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", hostname)) |
|
174 |
+ assert.Assert(c, err == nil, "%s", hostname) |
|
175 | 175 |
|
176 | 176 |
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "test", "--hostname", "{{.Service.Name}}-{{.Task.Slot}}-{{.Node.Hostname}}", "busybox", "top") |
177 | 177 |
assert.NilError(c, err, out) |
... | ... |
@@ -614,7 +614,7 @@ func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) { |
614 | 614 |
assert.NilError(c, err, out) |
615 | 615 |
lines := strings.Split(strings.Trim(out, "\n "), "\n") |
616 | 616 |
assert.Equal(c, len(lines), 1) |
617 |
- assert.Assert(c, lines[0] != bareID, fmt.Sprintf("Expected not %s, but got it for is-task label, output %q", bareID, out)) |
|
617 |
+ assert.Assert(c, lines[0] != bareID, "Expected not %s, but got it for is-task label, output %q", bareID, out) |
|
618 | 618 |
} |
619 | 619 |
|
620 | 620 |
const globalNetworkPlugin = "global-network-plugin" |
... | ... |
@@ -847,7 +847,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) { |
847 | 847 |
|
848 | 848 |
out, err = d.Cmd("exec", id, "cat", "/status") |
849 | 849 |
assert.NilError(c, err, out) |
850 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
850 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
851 | 851 |
// Remove service |
852 | 852 |
out, err = d.Cmd("service", "rm", name) |
853 | 853 |
assert.NilError(c, err, out) |
... | ... |
@@ -869,7 +869,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) { |
869 | 869 |
|
870 | 870 |
out, err = d.Cmd("exec", id, "cat", "/status") |
871 | 871 |
assert.NilError(c, err, out) |
872 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
872 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
873 | 873 |
} |
874 | 874 |
|
875 | 875 |
func (s *DockerSwarmSuite) TestSwarmServiceTTYUpdate(c *testing.T) { |
... | ... |
@@ -954,9 +954,9 @@ func (s *DockerSwarmSuite) TestDNSConfig(c *testing.T) { |
954 | 954 |
expectedOutput3 := "options timeout:3" |
955 | 955 |
out, err = d.Cmd("exec", id, "cat", "/etc/resolv.conf") |
956 | 956 |
assert.NilError(c, err, out) |
957 |
- assert.Assert(c, strings.Contains(out, expectedOutput1), fmt.Sprintf("Expected '%s', but got %q", expectedOutput1, out)) |
|
958 |
- assert.Assert(c, strings.Contains(out, expectedOutput2), fmt.Sprintf("Expected '%s', but got %q", expectedOutput2, out)) |
|
959 |
- assert.Assert(c, strings.Contains(out, expectedOutput3), fmt.Sprintf("Expected '%s', but got %q", expectedOutput3, out)) |
|
957 |
+ assert.Assert(c, strings.Contains(out, expectedOutput1), "Expected '%s', but got %q", expectedOutput1, out) |
|
958 |
+ assert.Assert(c, strings.Contains(out, expectedOutput2), "Expected '%s', but got %q", expectedOutput2, out) |
|
959 |
+ assert.Assert(c, strings.Contains(out, expectedOutput3), "Expected '%s', but got %q", expectedOutput3, out) |
|
960 | 960 |
} |
961 | 961 |
|
962 | 962 |
func (s *DockerSwarmSuite) TestDNSConfigUpdate(c *testing.T) { |
... | ... |
@@ -1043,7 +1043,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) { |
1043 | 1043 |
d := s.AddDaemon(c, false, false) |
1044 | 1044 |
|
1045 | 1045 |
outs, err := d.Cmd("swarm", "init", "--autolock") |
1046 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1046 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1047 | 1047 |
unlockKey := getUnlockKey(d, c, outs) |
1048 | 1048 |
|
1049 | 1049 |
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive) |
... | ... |
@@ -1068,15 +1068,15 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) { |
1068 | 1068 |
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive) |
1069 | 1069 |
|
1070 | 1070 |
outs, err = d.Cmd("node", "ls") |
1071 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1071 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1072 | 1072 |
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked")) |
1073 | 1073 |
outs, err = d.Cmd("swarm", "update", "--autolock=false") |
1074 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1074 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1075 | 1075 |
|
1076 | 1076 |
checkSwarmLockedToUnlocked(c, d) |
1077 | 1077 |
|
1078 | 1078 |
outs, err = d.Cmd("node", "ls") |
1079 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1079 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1080 | 1080 |
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked")) |
1081 | 1081 |
} |
1082 | 1082 |
|
... | ... |
@@ -1084,7 +1084,7 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) { |
1084 | 1084 |
d := s.AddDaemon(c, false, false) |
1085 | 1085 |
|
1086 | 1086 |
outs, err := d.Cmd("swarm", "init", "--autolock") |
1087 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1087 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1088 | 1088 |
|
1089 | 1089 |
// It starts off locked |
1090 | 1090 |
d.RestartNode(c) |
... | ... |
@@ -1099,13 +1099,13 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) { |
1099 | 1099 |
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and locked.")) |
1100 | 1100 |
// It is OK for user to leave a locked swarm with --force |
1101 | 1101 |
outs, err = d.Cmd("swarm", "leave", "--force") |
1102 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1102 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1103 | 1103 |
|
1104 | 1104 |
info = d.SwarmInfo(c) |
1105 | 1105 |
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive) |
1106 | 1106 |
|
1107 | 1107 |
outs, err = d.Cmd("swarm", "init") |
1108 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1108 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1109 | 1109 |
|
1110 | 1110 |
info = d.SwarmInfo(c) |
1111 | 1111 |
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive) |
... | ... |
@@ -1125,7 +1125,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) { |
1125 | 1125 |
|
1126 | 1126 |
// enable autolock |
1127 | 1127 |
outs, err := d1.Cmd("swarm", "update", "--autolock") |
1128 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1128 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1129 | 1129 |
unlockKey := getUnlockKey(d1, c, outs) |
1130 | 1130 |
|
1131 | 1131 |
// The ones that got the cluster update should be set to locked |
... | ... |
@@ -1147,7 +1147,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) { |
1147 | 1147 |
|
1148 | 1148 |
// leave it locked, and set the cluster to no longer autolock |
1149 | 1149 |
outs, err = d1.Cmd("swarm", "update", "--autolock=false") |
1150 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", outs)) |
|
1150 |
+ assert.Assert(c, err == nil, "out: %v", outs) |
|
1151 | 1151 |
|
1152 | 1152 |
// the ones that got the update are now set to unlocked |
1153 | 1153 |
for _, d := range []*daemon.Daemon{d1, d3} { |
... | ... |
@@ -1177,7 +1177,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) { |
1177 | 1177 |
|
1178 | 1178 |
// enable autolock |
1179 | 1179 |
outs, err := d1.Cmd("swarm", "update", "--autolock") |
1180 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", outs)) |
|
1180 |
+ assert.Assert(c, err == nil, "out: %v", outs) |
|
1181 | 1181 |
unlockKey := getUnlockKey(d1, c, outs) |
1182 | 1182 |
|
1183 | 1183 |
// joined workers start off unlocked |
... | ... |
@@ -1233,13 +1233,13 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) { |
1233 | 1233 |
d := s.AddDaemon(c, true, true) |
1234 | 1234 |
|
1235 | 1235 |
outs, err := d.Cmd("swarm", "update", "--autolock") |
1236 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", outs)) |
|
1236 |
+ assert.Assert(c, err == nil, "out: %v", outs) |
|
1237 | 1237 |
unlockKey := getUnlockKey(d, c, outs) |
1238 | 1238 |
|
1239 | 1239 |
// Rotate multiple times |
1240 | 1240 |
for i := 0; i != 3; i++ { |
1241 | 1241 |
outs, err = d.Cmd("swarm", "unlock-key", "-q", "--rotate") |
1242 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", outs)) |
|
1242 |
+ assert.Assert(c, err == nil, "out: %v", outs) |
|
1243 | 1243 |
// Strip \n |
1244 | 1244 |
newUnlockKey := outs[:len(outs)-1] |
1245 | 1245 |
assert.Assert(c, newUnlockKey != "") |
... | ... |
@@ -1320,13 +1320,13 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) { |
1320 | 1320 |
d3 := s.AddDaemon(c, true, true) |
1321 | 1321 |
|
1322 | 1322 |
outs, err := d1.Cmd("swarm", "update", "--autolock") |
1323 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1323 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1324 | 1324 |
unlockKey := getUnlockKey(d1, c, outs) |
1325 | 1325 |
|
1326 | 1326 |
// Rotate multiple times |
1327 | 1327 |
for i := 0; i != 3; i++ { |
1328 | 1328 |
outs, err = d1.Cmd("swarm", "unlock-key", "-q", "--rotate") |
1329 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1329 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1330 | 1330 |
// Strip \n |
1331 | 1331 |
newUnlockKey := outs[:len(outs)-1] |
1332 | 1332 |
assert.Assert(c, newUnlockKey != "") |
... | ... |
@@ -1385,7 +1385,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) { |
1385 | 1385 |
continue |
1386 | 1386 |
} |
1387 | 1387 |
} |
1388 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", outs)) |
|
1388 |
+ assert.Assert(c, err == nil, "%s", outs) |
|
1389 | 1389 |
assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked")) |
1390 | 1390 |
break |
1391 | 1391 |
} |
... | ... |
@@ -1401,7 +1401,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) { |
1401 | 1401 |
for i := 0; i < 2; i++ { |
1402 | 1402 |
// set to lock |
1403 | 1403 |
outs, err := d.Cmd("swarm", "update", "--autolock") |
1404 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", outs)) |
|
1404 |
+ assert.Assert(c, err == nil, "out: %v", outs) |
|
1405 | 1405 |
assert.Assert(c, strings.Contains(outs, "docker swarm unlock")) |
1406 | 1406 |
unlockKey := getUnlockKey(d, c, outs) |
1407 | 1407 |
|
... | ... |
@@ -1414,7 +1414,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) { |
1414 | 1414 |
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive) |
1415 | 1415 |
|
1416 | 1416 |
outs, err = d.Cmd("swarm", "update", "--autolock=false") |
1417 |
- assert.Assert(c, err == nil, fmt.Sprintf("out: %v", outs)) |
|
1417 |
+ assert.Assert(c, err == nil, "out: %v", outs) |
|
1418 | 1418 |
|
1419 | 1419 |
checkSwarmLockedToUnlocked(c, d) |
1420 | 1420 |
} |
... | ... |
@@ -1440,7 +1440,7 @@ func (s *DockerSwarmSuite) TestExtraHosts(c *testing.T) { |
1440 | 1440 |
expectedOutput := "1.2.3.4\texample.com" |
1441 | 1441 |
out, err = d.Cmd("exec", id, "cat", "/etc/hosts") |
1442 | 1442 |
assert.NilError(c, err, out) |
1443 |
- assert.Assert(c, strings.Contains(out, expectedOutput), fmt.Sprintf("Expected '%s', but got %q", expectedOutput, out)) |
|
1443 |
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out) |
|
1444 | 1444 |
} |
1445 | 1445 |
|
1446 | 1446 |
func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *testing.T) { |
... | ... |
@@ -1950,7 +1950,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsSecret(c *testing.T) { |
1950 | 1950 |
}, |
1951 | 1951 |
Data: []byte("TESTINGDATA"), |
1952 | 1952 |
}) |
1953 |
- assert.Assert(c, id != "", fmt.Sprintf("secrets: %s", id)) |
|
1953 |
+ assert.Assert(c, id != "", "secrets: %s", id) |
|
1954 | 1954 |
|
1955 | 1955 |
waitForEvent(c, d, "0", "-f scope=swarm", "secret create "+id, defaultRetryCount) |
1956 | 1956 |
|
... | ... |
@@ -1970,7 +1970,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *testing.T) { |
1970 | 1970 |
}, |
1971 | 1971 |
Data: []byte("TESTINGDATA"), |
1972 | 1972 |
}) |
1973 |
- assert.Assert(c, id != "", fmt.Sprintf("configs: %s", id)) |
|
1973 |
+ assert.Assert(c, id != "", "configs: %s", id) |
|
1974 | 1974 |
|
1975 | 1975 |
waitForEvent(c, d, "0", "-f scope=swarm", "config create "+id, defaultRetryCount) |
1976 | 1976 |
|
... | ... |
@@ -1982,7 +1982,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *testing.T) { |
1982 | 1982 |
|
1983 | 1983 |
func getUnlockKey(d *daemon.Daemon, c *testing.T, autolockOutput string) string { |
1984 | 1984 |
unlockKey, err := d.Cmd("swarm", "unlock-key", "-q") |
1985 |
- assert.Assert(c, err == nil, fmt.Sprintf("%s", unlockKey)) |
|
1985 |
+ assert.Assert(c, err == nil, "%s", unlockKey) |
|
1986 | 1986 |
unlockKey = strings.TrimSuffix(unlockKey, "\n") |
1987 | 1987 |
|
1988 | 1988 |
// Check that "docker swarm init --autolock" or "docker swarm update --autolock" |
... | ... |
@@ -59,7 +59,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) { |
59 | 59 |
assert.Equal(c, statNotExists.GID(), uint32(gid), "Created directory not owned by remapped root GID") |
60 | 60 |
|
61 | 61 |
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns") |
62 |
- assert.Assert(c, err == nil, fmt.Sprintf("Could not inspect running container: out: %q", pid)) |
|
62 |
+ assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid) |
|
63 | 63 |
// check the uid and gid maps for the PID to ensure root is remapped |
64 | 64 |
// (cmd = cat /proc/<pid>/uid_map | grep -E '0\s+9999\s+1') |
65 | 65 |
_, err = RunCommandPipelineWithOutput( |
... | ... |
@@ -80,7 +80,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) { |
80 | 80 |
|
81 | 81 |
// use host usernamespace |
82 | 82 |
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; top") |
83 |
- assert.Assert(c, err == nil, fmt.Sprintf("Output: %s", out)) |
|
83 |
+ assert.Assert(c, err == nil, "Output: %s", out) |
|
84 | 84 |
user = s.findUser(c, "userns_skip") |
85 | 85 |
// userns are skipped, user is root |
86 | 86 |
assert.Equal(c, user, "root") |
... | ... |
@@ -89,7 +89,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) { |
89 | 89 |
// findUser finds the uid or name of the user of the first process that runs in a container |
90 | 90 |
func (s *DockerDaemonSuite) findUser(c *testing.T, container string) string { |
91 | 91 |
out, err := s.d.Cmd("top", container) |
92 |
- assert.Assert(c, err == nil, fmt.Sprintf("Output: %s", out)) |
|
92 |
+ assert.Assert(c, err == nil, "Output: %s", out) |
|
93 | 93 |
rows := strings.Split(out, "\n") |
94 | 94 |
if len(rows) < 2 { |
95 | 95 |
// No process rows founds |
... | ... |
@@ -146,13 +146,13 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) { |
146 | 146 |
|
147 | 147 |
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output |
148 | 148 |
assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output") |
149 |
- assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), fmt.Sprintf("volume 'testisinuse1' in output, but not expected")) |
|
150 |
- assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), fmt.Sprintf("volume 'testisinuse2' in output, but not expected")) |
|
149 |
+ assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), "volume 'testisinuse1' in output, but not expected") |
|
150 |
+ assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), "volume 'testisinuse2' in output, but not expected") |
|
151 | 151 |
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=1") |
152 | 152 |
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output, dangling also accept 1 |
153 | 153 |
assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output") |
154 |
- assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), fmt.Sprintf("volume 'testisinuse1' in output, but not expected")) |
|
155 |
- assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), fmt.Sprintf("volume 'testisinuse2' in output, but not expected")) |
|
154 |
+ assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), "volume 'testisinuse1' in output, but not expected") |
|
155 |
+ assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), "volume 'testisinuse2' in output, but not expected") |
|
156 | 156 |
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=0") |
157 | 157 |
// dangling=0 is same as dangling=false case |
158 | 158 |
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output") |
... | ... |
@@ -235,7 +235,7 @@ func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) { |
235 | 235 |
name := strings.TrimSpace(out) |
236 | 236 |
|
237 | 237 |
out, exitCode, err := dockerCmdWithError("volume", "inspect", "--format='{{ .FooBar }}'", name) |
238 |
- assert.Assert(c, err != nil, fmt.Sprintf("Output: %s", out)) |
|
238 |
+ assert.Assert(c, err != nil, "Output: %s", out) |
|
239 | 239 |
assert.Equal(c, exitCode, 1, fmt.Sprintf("Output: %s", out)) |
240 | 240 |
assert.Assert(c, strings.Contains(out, "Template parsing error")) |
241 | 241 |
} |
... | ... |
@@ -474,7 +474,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) { |
474 | 474 |
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1)) |
475 | 475 |
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2)) |
476 | 476 |
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-d", "busybox", "top") |
477 |
- assert.Assert(c, err == nil, fmt.Sprintf("Out: %s", out)) |
|
477 |
+ assert.Assert(c, err == nil, "Out: %s", out) |
|
478 | 478 |
|
479 | 479 |
// Only the second volume will be referenced, this is backward compatible |
480 | 480 |
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app") |
... | ... |
@@ -516,7 +516,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T |
516 | 516 |
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2)) |
517 | 517 |
// /tmp/data is automatically created, because we are not using the modern mount API here |
518 | 518 |
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-v", "/tmp/data:/tmp/data", "-d", "busybox", "top") |
519 |
- assert.Assert(c, err == nil, fmt.Sprintf("Out: %s", out)) |
|
519 |
+ assert.Assert(c, err == nil, "Out: %s", out) |
|
520 | 520 |
|
521 | 521 |
// No volume will be referenced (mount is /tmp/data), this is backward compatible |
522 | 522 |
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app") |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
package main |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
5 | 4 |
"os/exec" |
6 | 5 |
"strings" |
7 | 6 |
"testing" |
... | ... |
@@ -62,7 +61,7 @@ func (s *DockerHubPullSuite) TearDownTest(c *testing.T) { |
62 | 62 |
// output. The function fails the test when the command returns an error. |
63 | 63 |
func (s *DockerHubPullSuite) Cmd(c *testing.T, name string, arg ...string) string { |
64 | 64 |
out, err := s.CmdWithError(name, arg...) |
65 |
- assert.Assert(c, err == nil, fmt.Sprintf("%q failed with errors: %s, %v", strings.Join(arg, " "), out, err)) |
|
65 |
+ assert.Assert(c, err == nil, "%q failed with errors: %s, %v", strings.Join(arg, " "), out, err) |
|
66 | 66 |
return out |
67 | 67 |
} |
68 | 68 |
|
... | ... |
@@ -82,7 +82,7 @@ func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interfac |
82 | 82 |
str := inspectFieldJSON(c, name, field) |
83 | 83 |
err := json.Unmarshal([]byte(str), output) |
84 | 84 |
if c != nil { |
85 |
- assert.Assert(c, err == nil, fmt.Sprintf("failed to unmarshal: %v", err)) |
|
85 |
+ assert.Assert(c, err == nil, "failed to unmarshal: %v", err) |
|
86 | 86 |
} |
87 | 87 |
} |
88 | 88 |
|