Browse code

integration-cli: remove uses of deprecated dockerCmdWithResult utility

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/06/30 19:19:55
Showing 6 changed files
... ...
@@ -100,7 +100,7 @@ func (s *DockerCLIEventSuite) TestEventsOOMDisableTrue(c *testing.T) {
100 100
 	}()
101 101
 
102 102
 	cli.WaitRun(c, "oomTrue")
103
-	defer dockerCmdWithResult("kill", "oomTrue")
103
+	defer cli.Docker(cli.Args("kill", "oomTrue"))
104 104
 	containerID := inspectField(c, "oomTrue", "Id")
105 105
 
106 106
 	testActions := map[string]chan bool{
... ...
@@ -327,14 +327,14 @@ func (s *DockerCLIInspectSuite) TestInspectByPrefix(c *testing.T) {
327 327
 func (s *DockerCLIInspectSuite) TestInspectStopWhenNotFound(c *testing.T) {
328 328
 	runSleepingContainer(c, "--name=busybox1", "-d")
329 329
 	runSleepingContainer(c, "--name=busybox2", "-d")
330
-	result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing")
330
+	result := cli.Docker(cli.Args("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing"))
331 331
 
332 332
 	assert.Assert(c, result.Error != nil)
333 333
 	assert.Assert(c, is.Contains(result.Stdout(), "busybox1"))
334 334
 	assert.Assert(c, is.Contains(result.Stdout(), "busybox2"))
335 335
 	assert.Assert(c, is.Contains(result.Stderr(), "Error: No such container: missing"))
336 336
 	// test inspect would not fast fail
337
-	result = dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "missing", "busybox1", "busybox2")
337
+	result = cli.Docker(cli.Args("inspect", "--type=container", "--format='{{.Name}}'", "missing", "busybox1", "busybox2"))
338 338
 
339 339
 	assert.Assert(c, result.Error != nil)
340 340
 	assert.Assert(c, is.Contains(result.Stdout(), "busybox1"))
... ...
@@ -465,7 +465,7 @@ func (s *DockerCLINetworkSuite) TestDockerNetworkInspectWithID(c *testing.T) {
465 465
 }
466 466
 
467 467
 func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetwork(c *testing.T) {
468
-	result := dockerCmdWithResult("network", "inspect", "host", "none")
468
+	result := cli.Docker(cli.Args("network", "inspect", "host", "none"))
469 469
 	result.Assert(c, icmd.Success)
470 470
 
471 471
 	var networkResources []network.Inspect
... ...
@@ -477,7 +477,7 @@ func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetwork(c *testing.T) {
477 477
 func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *testing.T) {
478 478
 	// non-existent network was not at the beginning of the inspect list
479 479
 	// This should print an error, return an exitCode 1 and print the host network
480
-	result := dockerCmdWithResult("network", "inspect", "host", "nonexistent")
480
+	result := cli.Docker(cli.Args("network", "inspect", "host", "nonexistent"))
481 481
 	result.Assert(c, icmd.Expected{
482 482
 		ExitCode: 1,
483 483
 		Err:      "Error: No such network: nonexistent",
... ...
@@ -491,7 +491,7 @@ func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetworksIncludingNonexi
491 491
 
492 492
 	// Only one non-existent network to inspect
493 493
 	// Should print an error and return an exitCode, nothing else
494
-	result = dockerCmdWithResult("network", "inspect", "nonexistent")
494
+	result = cli.Docker(cli.Args("network", "inspect", "nonexistent"))
495 495
 	result.Assert(c, icmd.Expected{
496 496
 		ExitCode: 1,
497 497
 		Err:      "Error: No such network: nonexistent",
... ...
@@ -500,7 +500,7 @@ func (s *DockerCLINetworkSuite) TestDockerInspectMultipleNetworksIncludingNonexi
500 500
 
501 501
 	// non-existent network was at the beginning of the inspect list
502 502
 	// Should not fail fast, and still print host network but print an error
503
-	result = dockerCmdWithResult("network", "inspect", "nonexistent", "host")
503
+	result = cli.Docker(cli.Args("network", "inspect", "nonexistent", "host"))
504 504
 	result.Assert(c, icmd.Expected{
505 505
 		ExitCode: 1,
506 506
 		Err:      "Error: No such network: nonexistent",
... ...
@@ -2441,10 +2441,10 @@ func (s *DockerCLIRunSuite) TestRunTLSVerify(c *testing.T) {
2441 2441
 
2442 2442
 	// Regardless of whether we specify true or false we need to
2443 2443
 	// test to make sure tls is turned on if --tlsverify is specified at all
2444
-	result := dockerCmdWithResult("--tlsverify=false", "ps")
2444
+	result := cli.Docker(cli.Args("--tlsverify=false", "ps"))
2445 2445
 	result.Assert(c, icmd.Expected{ExitCode: 1, Err: "error during connect"})
2446 2446
 
2447
-	result = dockerCmdWithResult("--tlsverify=true", "ps")
2447
+	result = cli.Docker(cli.Args("--tlsverify=true", "ps"))
2448 2448
 	result.Assert(c, icmd.Expected{ExitCode: 1, Err: "cert"})
2449 2449
 }
2450 2450
 
... ...
@@ -3804,9 +3804,9 @@ func (s *DockerCLIRunSuite) TestRunAttachFailedNoLeak(c *testing.T) {
3804 3804
 	_, err := d.Cmd("run", "--rm", "busybox", "true")
3805 3805
 	assert.NilError(c, err)
3806 3806
 
3807
-	client := d.NewClientT(c)
3807
+	apiClient := d.NewClientT(c)
3808 3808
 
3809
-	nroutines := waitForStableGoroutineCount(ctx, c, client)
3809
+	nroutines := waitForStableGoroutineCount(ctx, c, apiClient)
3810 3810
 
3811 3811
 	out, err := d.Cmd(append([]string{"run", "-d", "--name=test", "-p", "8000:8000", "busybox"}, sleepCommandForDaemonPlatform()...)...)
3812 3812
 	assert.NilError(c, err, out)
... ...
@@ -3834,7 +3834,7 @@ func (s *DockerCLIRunSuite) TestRunAttachFailedNoLeak(c *testing.T) {
3834 3834
 	assert.NilError(c, err, out)
3835 3835
 
3836 3836
 	// NGoroutines is not updated right away, so we need to wait before failing
3837
-	waitForGoroutines(ctx, c, client, nroutines)
3837
+	waitForGoroutines(ctx, c, apiClient, nroutines)
3838 3838
 }
3839 3839
 
3840 3840
 // Test for one character directory name case (#20122)
... ...
@@ -66,7 +66,7 @@ func (s *DockerCLIVolumeSuite) TestVolumeCLIInspectMulti(c *testing.T) {
66 66
 	cli.DockerCmd(c, "volume", "create", "test2")
67 67
 	cli.DockerCmd(c, "volume", "create", "test3")
68 68
 
69
-	result := dockerCmdWithResult("volume", "inspect", "--format={{ .Name }}", "test1", "test2", "doesnotexist", "test3")
69
+	result := cli.Docker(cli.Args("volume", "inspect", "--format={{ .Name }}", "test1", "test2", "doesnotexist", "test3"))
70 70
 	result.Assert(c, icmd.Expected{
71 71
 		ExitCode: 1,
72 72
 		Err:      "No such volume: doesnotexist",
... ...
@@ -42,11 +42,6 @@ func dockerCmdWithError(args ...string) (string, int, error) {
42 42
 	return result.Combined(), result.ExitCode, result.Error
43 43
 }
44 44
 
45
-// Deprecated: use cli.Docker or cli.DockerCmd
46
-func dockerCmdWithResult(args ...string) *icmd.Result {
47
-	return cli.Docker(cli.Args(args...))
48
-}
49
-
50 45
 func findContainerIP(t *testing.T, id string, network string) string {
51 46
 	t.Helper()
52 47
 	out := cli.DockerCmd(t, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id).Stdout()