Browse code

integration-cli: DockerCLISearchSuite: replace dockerCmd

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

Sebastiaan van Stijn authored on 2023/07/28 04:52:44
Showing 1 changed files
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"strings"
7 7
 	"testing"
8 8
 
9
+	"github.com/docker/docker/integration-cli/cli"
9 10
 	"gotest.tools/v3/assert"
10 11
 )
11 12
 
... ...
@@ -23,7 +24,7 @@ func (s *DockerCLISearchSuite) OnTimeout(c *testing.T) {
23 23
 
24 24
 // search for repos named  "registry" on the central registry
25 25
 func (s *DockerCLISearchSuite) TestSearchOnCentralRegistry(c *testing.T) {
26
-	out, _ := dockerCmd(c, "search", "busybox")
26
+	out := cli.DockerCmd(c, "search", "busybox").Stdout()
27 27
 	assert.Assert(c, strings.Contains(out, "Busybox base image."), "couldn't find any repository named (or containing) 'Busybox base image.'")
28 28
 }
29 29
 
... ...
@@ -46,35 +47,35 @@ func (s *DockerCLISearchSuite) TestSearchStarsOptionWithWrongParameter(c *testin
46 46
 }
47 47
 
48 48
 func (s *DockerCLISearchSuite) TestSearchCmdOptions(c *testing.T) {
49
-	outSearchCmd, _ := dockerCmd(c, "search", "busybox")
49
+	outSearchCmd := cli.DockerCmd(c, "search", "busybox").Combined()
50 50
 	assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd)
51 51
 
52
-	outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") // The busybox is a busybox base image, not an AUTOMATED image.
52
+	outSearchCmdautomated := cli.DockerCmd(c, "search", "--filter", "is-automated=true", "busybox").Combined() // The busybox is a busybox base image, not an AUTOMATED image.
53 53
 	outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n")
54 54
 	for i := range outSearchCmdautomatedSlice {
55 55
 		assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated)
56 56
 	}
57 57
 
58
-	outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") // The busybox is a busybox base image, official image.
58
+	outSearchCmdNotOfficial := cli.DockerCmd(c, "search", "--filter", "is-official=false", "busybox").Combined() // The busybox is a busybox base image, official image.
59 59
 	outSearchCmdNotOfficialSlice := strings.Split(outSearchCmdNotOfficial, "\n")
60 60
 	for i := range outSearchCmdNotOfficialSlice {
61 61
 		assert.Assert(c, !strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), "The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial)
62 62
 	}
63 63
 
64
-	outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") // The busybox is a busybox base image, official image.
64
+	outSearchCmdOfficial := cli.DockerCmd(c, "search", "--filter", "is-official=true", "busybox").Combined() // The busybox is a busybox base image, official image.
65 65
 	outSearchCmdOfficialSlice := strings.Split(outSearchCmdOfficial, "\n")
66 66
 	assert.Equal(c, len(outSearchCmdOfficialSlice), 3) // 1 header, 1 line, 1 carriage return
67 67
 	assert.Assert(c, strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), "The busybox is an OFFICIAL image: %s", outSearchCmdOfficial)
68 68
 
69
-	outSearchCmdStars, _ := dockerCmd(c, "search", "--filter", "stars=10", "busybox")
69
+	outSearchCmdStars := cli.DockerCmd(c, "search", "--filter", "stars=10", "busybox").Combined()
70 70
 	assert.Assert(c, strings.Count(outSearchCmdStars, "\n") <= strings.Count(outSearchCmd, "\n"), "Number of images with 10+ stars should be less than that of all images:\noutSearchCmdStars: %s\noutSearch: %s\n", outSearchCmdStars, outSearchCmd)
71 71
 
72
-	dockerCmd(c, "search", "--filter", "is-automated=true", "--filter", "stars=2", "--no-trunc=true", "busybox")
72
+	cli.DockerCmd(c, "search", "--filter", "is-automated=true", "--filter", "stars=2", "--no-trunc=true", "busybox")
73 73
 }
74 74
 
75 75
 // search for repos which start with "ubuntu-" on the central registry
76 76
 func (s *DockerCLISearchSuite) TestSearchOnCentralRegistryWithDash(c *testing.T) {
77
-	dockerCmd(c, "search", "ubuntu-")
77
+	cli.DockerCmd(c, "search", "ubuntu-")
78 78
 }
79 79
 
80 80
 // test case for #23055