Browse code

integration/system: rename vars to prevent shadowing imports

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

Sebastiaan van Stijn authored on 2024/09/11 03:17:08
Showing 7 changed files
... ...
@@ -25,7 +25,7 @@ func TestDiskUsage(t *testing.T) {
25 25
 	defer d.Cleanup(t)
26 26
 	d.Start(t, "--iptables=false", "--ip6tables=false")
27 27
 	defer d.Stop(t)
28
-	client := d.NewClientT(t)
28
+	apiClient := d.NewClientT(t)
29 29
 
30 30
 	var stepDU types.DiskUsage
31 31
 	for _, step := range []struct {
... ...
@@ -35,7 +35,7 @@ func TestDiskUsage(t *testing.T) {
35 35
 		{
36 36
 			doc: "empty",
37 37
 			next: func(t *testing.T, _ types.DiskUsage) types.DiskUsage {
38
-				du, err := client.DiskUsage(ctx, types.DiskUsageOptions{})
38
+				du, err := apiClient.DiskUsage(ctx, types.DiskUsageOptions{})
39 39
 				assert.NilError(t, err)
40 40
 
41 41
 				expectedLayersSize := int64(0)
... ...
@@ -62,7 +62,7 @@ func TestDiskUsage(t *testing.T) {
62 62
 			next: func(t *testing.T, _ types.DiskUsage) types.DiskUsage {
63 63
 				d.LoadBusybox(ctx, t)
64 64
 
65
-				du, err := client.DiskUsage(ctx, types.DiskUsageOptions{})
65
+				du, err := apiClient.DiskUsage(ctx, types.DiskUsageOptions{})
66 66
 				assert.NilError(t, err)
67 67
 				assert.Assert(t, du.LayersSize > 0)
68 68
 				assert.Equal(t, len(du.Images), 1)
... ...
@@ -84,9 +84,9 @@ func TestDiskUsage(t *testing.T) {
84 84
 		{
85 85
 			doc: "after container.Run",
86 86
 			next: func(t *testing.T, prev types.DiskUsage) types.DiskUsage {
87
-				cID := container.Run(ctx, t, client)
87
+				cID := container.Run(ctx, t, apiClient)
88 88
 
89
-				du, err := client.DiskUsage(ctx, types.DiskUsageOptions{})
89
+				du, err := apiClient.DiskUsage(ctx, types.DiskUsageOptions{})
90 90
 				assert.NilError(t, err)
91 91
 				assert.Equal(t, len(du.Containers), 1)
92 92
 				assert.Equal(t, len(du.Containers[0].Names), 1)
... ...
@@ -263,7 +263,7 @@ func TestDiskUsage(t *testing.T) {
263 263
 					ctx := testutil.StartSpan(ctx, t)
264 264
 					// TODO: Run in parallel once https://github.com/moby/moby/pull/42560 is merged.
265 265
 
266
-					du, err := client.DiskUsage(ctx, tc.options)
266
+					du, err := apiClient.DiskUsage(ctx, tc.options)
267 267
 					assert.NilError(t, err)
268 268
 					assert.DeepEqual(t, du, tc.expected)
269 269
 				})
... ...
@@ -28,23 +28,23 @@ import (
28 28
 func TestEventsExecDie(t *testing.T) {
29 29
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME. Suspect may need to wait until container is running before exec")
30 30
 	ctx := setupTest(t)
31
-	client := testEnv.APIClient()
31
+	apiClient := testEnv.APIClient()
32 32
 
33
-	cID := container.Run(ctx, t, client)
33
+	cID := container.Run(ctx, t, apiClient)
34 34
 
35
-	id, err := client.ContainerExecCreate(ctx, cID, containertypes.ExecOptions{
35
+	id, err := apiClient.ContainerExecCreate(ctx, cID, containertypes.ExecOptions{
36 36
 		Cmd: []string{"echo", "hello"},
37 37
 	})
38 38
 	assert.NilError(t, err)
39 39
 
40
-	msg, errs := client.Events(ctx, events.ListOptions{
40
+	msg, errs := apiClient.Events(ctx, events.ListOptions{
41 41
 		Filters: filters.NewArgs(
42 42
 			filters.Arg("container", cID),
43 43
 			filters.Arg("event", string(events.ActionExecDie)),
44 44
 		),
45 45
 	})
46 46
 
47
-	err = client.ContainerExecStart(ctx, id.ID, containertypes.ExecStartOptions{
47
+	err = apiClient.ContainerExecStart(ctx, id.ID, containertypes.ExecStartOptions{
48 48
 		Detach: true,
49 49
 		Tty:    false,
50 50
 	})
... ...
@@ -71,12 +71,12 @@ func TestEventsExecDie(t *testing.T) {
71 71
 func TestEventsBackwardsCompatible(t *testing.T) {
72 72
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "Windows doesn't support back-compat messages")
73 73
 	ctx := setupTest(t)
74
-	client := testEnv.APIClient()
74
+	apiClient := testEnv.APIClient()
75 75
 
76
-	since := request.DaemonTime(ctx, t, client, testEnv)
76
+	since := request.DaemonTime(ctx, t, apiClient, testEnv)
77 77
 	ts := strconv.FormatInt(since.Unix(), 10)
78 78
 
79
-	cID := container.Create(ctx, t, client)
79
+	cID := container.Create(ctx, t, apiClient)
80 80
 
81 81
 	// In case there is no events, the API should have responded immediately (not blocking),
82 82
 	// The test here makes sure the response time is less than 3 sec.
... ...
@@ -125,9 +125,9 @@ func TestEventsVolumeCreate(t *testing.T) {
125 125
 	ctx, cancel := context.WithCancel(ctx)
126 126
 	defer cancel()
127 127
 
128
-	client := testEnv.APIClient()
128
+	apiClient := testEnv.APIClient()
129 129
 
130
-	since := request.DaemonUnixTime(ctx, t, client, testEnv)
130
+	since := request.DaemonUnixTime(ctx, t, apiClient, testEnv)
131 131
 	volName := t.Name()
132 132
 	getEvents := func(messages <-chan events.Message, errs <-chan error) ([]events.Message, error) {
133 133
 		var evts []events.Message
... ...
@@ -147,7 +147,7 @@ func TestEventsVolumeCreate(t *testing.T) {
147 147
 		}
148 148
 	}
149 149
 
150
-	_, err := client.VolumeCreate(ctx, volume.CreateOptions{Name: volName})
150
+	_, err := apiClient.VolumeCreate(ctx, volume.CreateOptions{Name: volName})
151 151
 	assert.NilError(t, err)
152 152
 
153 153
 	filter := filters.NewArgs(
... ...
@@ -155,9 +155,9 @@ func TestEventsVolumeCreate(t *testing.T) {
155 155
 		filters.Arg("event", "create"),
156 156
 		filters.Arg("volume", volName),
157 157
 	)
158
-	messages, errs := client.Events(ctx, events.ListOptions{
158
+	messages, errs := apiClient.Events(ctx, events.ListOptions{
159 159
 		Since:   since,
160
-		Until:   request.DaemonUnixTime(ctx, t, client, testEnv),
160
+		Until:   request.DaemonUnixTime(ctx, t, apiClient, testEnv),
161 161
 		Filters: filter,
162 162
 	})
163 163
 
... ...
@@ -165,15 +165,15 @@ func TestEventsVolumeCreate(t *testing.T) {
165 165
 	assert.NilError(t, err)
166 166
 	assert.Equal(t, len(volEvents), 1, "expected volume create event when creating a volume")
167 167
 
168
-	container.Create(ctx, t, client, container.WithMount(mount.Mount{
168
+	container.Create(ctx, t, apiClient, container.WithMount(mount.Mount{
169 169
 		Type:   mount.TypeVolume,
170 170
 		Source: volName,
171 171
 		Target: "/tmp/foo",
172 172
 	}))
173 173
 
174
-	messages, errs = client.Events(ctx, events.ListOptions{
174
+	messages, errs = apiClient.Events(ctx, events.ListOptions{
175 175
 		Since:   since,
176
-		Until:   request.DaemonUnixTime(ctx, t, client, testEnv),
176
+		Until:   request.DaemonUnixTime(ctx, t, apiClient, testEnv),
177 177
 		Filters: filter,
178 178
 	})
179 179
 
... ...
@@ -11,9 +11,9 @@ import (
11 11
 
12 12
 func TestInfoBinaryCommits(t *testing.T) {
13 13
 	ctx := setupTest(t)
14
-	client := testEnv.APIClient()
14
+	apiClient := testEnv.APIClient()
15 15
 
16
-	info, err := client.Info(ctx)
16
+	info, err := apiClient.Info(ctx)
17 17
 	assert.NilError(t, err)
18 18
 
19 19
 	assert.Check(t, "N/A" != info.ContainerdCommit.ID)
... ...
@@ -15,9 +15,9 @@ import (
15 15
 
16 16
 func TestInfoAPI(t *testing.T) {
17 17
 	ctx := setupTest(t)
18
-	client := testEnv.APIClient()
18
+	apiClient := testEnv.APIClient()
19 19
 
20
-	info, err := client.Info(ctx)
20
+	info, err := apiClient.Info(ctx)
21 21
 	assert.NilError(t, err)
22 22
 
23 23
 	// TODO(thaJeztah): make sure we have other tests that run a local daemon and check other fields based on known state.
... ...
@@ -17,13 +17,12 @@ func TestLoginFailsWithBadCredentials(t *testing.T) {
17 17
 	skip.If(t, !requirement.HasHubConnectivity(t))
18 18
 
19 19
 	ctx := setupTest(t)
20
-	client := testEnv.APIClient()
20
+	apiClient := testEnv.APIClient()
21 21
 
22
-	config := registry.AuthConfig{
22
+	_, err := apiClient.RegistryLogin(ctx, registry.AuthConfig{
23 23
 		Username: "no-user",
24 24
 		Password: "no-password",
25
-	}
26
-	_, err := client.RegistryLogin(ctx, config)
25
+	})
27 26
 	assert.Assert(t, err != nil)
28 27
 	assert.Check(t, is.ErrorContains(err, "unauthorized: incorrect username or password"))
29 28
 	assert.Check(t, is.ErrorContains(err, fmt.Sprintf("https://%s/v2/", registrypkg.DefaultRegistryHost)))
... ...
@@ -62,34 +62,34 @@ func TestPingSwarmHeader(t *testing.T) {
62 62
 	d := daemon.New(t)
63 63
 	d.Start(t)
64 64
 	defer d.Stop(t)
65
-	client := d.NewClientT(t)
66
-	defer client.Close()
65
+	apiClient := d.NewClientT(t)
66
+	defer apiClient.Close()
67 67
 
68 68
 	t.Run("before swarm init", func(t *testing.T) {
69 69
 		ctx := testutil.StartSpan(ctx, t)
70
-		p, err := client.Ping(ctx)
70
+		p, err := apiClient.Ping(ctx)
71 71
 		assert.NilError(t, err)
72 72
 		assert.Equal(t, p.SwarmStatus.NodeState, swarm.LocalNodeStateInactive)
73 73
 		assert.Equal(t, p.SwarmStatus.ControlAvailable, false)
74 74
 	})
75 75
 
76
-	_, err := client.SwarmInit(ctx, swarm.InitRequest{ListenAddr: "127.0.0.1", AdvertiseAddr: "127.0.0.1:2377"})
76
+	_, err := apiClient.SwarmInit(ctx, swarm.InitRequest{ListenAddr: "127.0.0.1", AdvertiseAddr: "127.0.0.1:2377"})
77 77
 	assert.NilError(t, err)
78 78
 
79 79
 	t.Run("after swarm init", func(t *testing.T) {
80 80
 		ctx := testutil.StartSpan(ctx, t)
81
-		p, err := client.Ping(ctx)
81
+		p, err := apiClient.Ping(ctx)
82 82
 		assert.NilError(t, err)
83 83
 		assert.Equal(t, p.SwarmStatus.NodeState, swarm.LocalNodeStateActive)
84 84
 		assert.Equal(t, p.SwarmStatus.ControlAvailable, true)
85 85
 	})
86 86
 
87
-	err = client.SwarmLeave(ctx, true)
87
+	err = apiClient.SwarmLeave(ctx, true)
88 88
 	assert.NilError(t, err)
89 89
 
90 90
 	t.Run("after swarm leave", func(t *testing.T) {
91 91
 		ctx := testutil.StartSpan(ctx, t)
92
-		p, err := client.Ping(ctx)
92
+		p, err := apiClient.Ping(ctx)
93 93
 		assert.NilError(t, err)
94 94
 		assert.Equal(t, p.SwarmStatus.NodeState, swarm.LocalNodeStateInactive)
95 95
 		assert.Equal(t, p.SwarmStatus.ControlAvailable, false)
... ...
@@ -102,8 +102,8 @@ func TestPingBuilderHeader(t *testing.T) {
102 102
 
103 103
 	ctx := setupTest(t)
104 104
 	d := daemon.New(t)
105
-	client := d.NewClientT(t)
106
-	defer client.Close()
105
+	apiClient := d.NewClientT(t)
106
+	defer apiClient.Close()
107 107
 
108 108
 	t.Run("default config", func(t *testing.T) {
109 109
 		testutil.StartSpan(ctx, t)
... ...
@@ -115,7 +115,7 @@ func TestPingBuilderHeader(t *testing.T) {
115 115
 			expected = types.BuilderV1
116 116
 		}
117 117
 
118
-		p, err := client.Ping(ctx)
118
+		p, err := apiClient.Ping(ctx)
119 119
 		assert.NilError(t, err)
120 120
 		assert.Equal(t, p.BuilderVersion, expected)
121 121
 	})
... ...
@@ -129,7 +129,7 @@ func TestPingBuilderHeader(t *testing.T) {
129 129
 		defer d.Stop(t)
130 130
 
131 131
 		expected := types.BuilderV1
132
-		p, err := client.Ping(ctx)
132
+		p, err := apiClient.Ping(ctx)
133 133
 		assert.NilError(t, err)
134 134
 		assert.Equal(t, p.BuilderVersion, expected)
135 135
 	})
... ...
@@ -9,9 +9,9 @@ import (
9 9
 
10 10
 func TestVersion(t *testing.T) {
11 11
 	ctx := setupTest(t)
12
-	client := testEnv.APIClient()
12
+	apiClient := testEnv.APIClient()
13 13
 
14
-	version, err := client.ServerVersion(ctx)
14
+	version, err := apiClient.ServerVersion(ctx)
15 15
 	assert.NilError(t, err)
16 16
 
17 17
 	assert.Check(t, version.APIVersion != "")