Skip to content

Commit 881510e

Browse files
fix(lint): appease linter
1 parent 7d40667 commit 881510e

File tree

24 files changed

+72
-87
lines changed

24 files changed

+72
-87
lines changed

common/pkg/capi/clustertopology/handlers/lifecycle/parallel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func Test_runHooksInParallel(t *testing.T) {
248248

249249
gotResponse := &runtimehooksv1.BeforeClusterUpgradeResponse{}
250250
runHooksInParallel(
251-
context.Background(),
251+
t.Context(),
252252
hookFuncs,
253253
&runtimehooksv1.BeforeClusterUpgradeRequest{},
254254
gotResponse,

common/pkg/capi/clustertopology/handlers/mutation/meta_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func TestMetaGeneratePatches(t *testing.T) {
221221
h := NewMetaGeneratePatchesHandler("", nil, tt.mutaters...).(GeneratePatches)
222222

223223
resp := &runtimehooksv1.GeneratePatchesResponse{}
224-
h.GeneratePatches(context.Background(), &runtimehooksv1.GeneratePatchesRequest{
224+
h.GeneratePatches(t.Context(), &runtimehooksv1.GeneratePatchesRequest{
225225
Items: []runtimehooksv1.GeneratePatchesRequestItem{
226226
request.NewKubeadmConfigTemplateRequestItem("kubeadm-config"),
227227
request.NewKubeadmControlPlaneTemplateRequestItem("kubeadm-control-plane"),

common/pkg/capi/utils/utils_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package utils
55

66
import (
7-
"context"
87
"fmt"
98
"testing"
109

@@ -223,7 +222,7 @@ func TestManagementOrFutureManagementCluster(t *testing.T) {
223222
t.Parallel()
224223
cl := buildFakeClientForTest(t, tt.initialClusters, tt.nodes)
225224

226-
cluster, err := ManagementOrFutureManagementCluster(context.Background(), cl)
225+
cluster, err := ManagementOrFutureManagementCluster(t.Context(), cl)
227226
if tt.wantErr != nil {
228227
require.EqualError(t, err, tt.wantErr.Error())
229228
} else {

common/pkg/testutils/capitest/variables.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package capitest
55

66
import (
7-
"context"
87
"encoding/json"
98
"testing"
109

@@ -60,7 +59,7 @@ func ValidateDiscoverVariablesAs[V mutation.DiscoverVariables, T any](
6059
h := handlerCreator()
6160
resp := &runtimehooksv1.DiscoverVariablesResponse{}
6261
h.DiscoverVariables(
63-
context.Background(),
62+
t.Context(),
6463
&runtimehooksv1.DiscoverVariablesRequest{},
6564
resp,
6665
)

pkg/controllers/failuredomainrollout/controller_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package failuredomainrollout
55

66
import (
7-
"context"
87
"testing"
98
"time"
109

@@ -290,7 +289,7 @@ func TestReconciler_shouldTriggerRollout(t *testing.T) {
290289
Client: fakeClient,
291290
}
292291

293-
needsRollout, reason, err := r.shouldTriggerRollout(context.Background(), tt.cluster, tt.kcp)
292+
needsRollout, reason, err := r.shouldTriggerRollout(t.Context(), tt.cluster, tt.kcp)
294293
require.NoError(t, err)
295294
require.Equal(t, tt.expectedRollout, needsRollout)
296295
if tt.expectedReason != "" {
@@ -525,7 +524,7 @@ func TestReconciler_shouldImproveDistribution(t *testing.T) {
525524
}
526525

527526
// Get current distribution from the fake client
528-
currentDistribution, err := r.getMachineDistribution(context.Background(), cluster)
527+
currentDistribution, err := r.getMachineDistribution(t.Context(), cluster)
529528
require.NoError(t, err)
530529

531530
shouldImprove := r.shouldImproveDistribution(
@@ -1453,7 +1452,7 @@ func TestReconciler_Reconcile(t *testing.T) {
14531452
NamespacedName: client.ObjectKeyFromObject(tt.cluster),
14541453
}
14551454

1456-
result, err := r.Reconcile(context.Background(), req)
1455+
result, err := r.Reconcile(t.Context(), req)
14571456
require.NoError(t, err, "Reconciliation should not fail")
14581457

14591458
// Check for requeue scenarios
@@ -1467,7 +1466,7 @@ func TestReconciler_Reconcile(t *testing.T) {
14671466

14681467
// Verify the KCP was NOT updated in requeue scenarios
14691468
var updatedKCP controlplanev1.KubeadmControlPlane
1470-
err = fakeClient.Get(context.Background(), client.ObjectKeyFromObject(tt.kcp), &updatedKCP)
1469+
err = fakeClient.Get(t.Context(), client.ObjectKeyFromObject(tt.kcp), &updatedKCP)
14711470
require.NoError(t, err, "Should be able to get KCP")
14721471
require.Equal(
14731472
t,
@@ -1480,7 +1479,7 @@ func TestReconciler_Reconcile(t *testing.T) {
14801479

14811480
// Verify the KCP was updated correctly for normal scenarios
14821481
var updatedKCP controlplanev1.KubeadmControlPlane
1483-
err = fakeClient.Get(context.Background(), client.ObjectKeyFromObject(tt.kcp), &updatedKCP)
1482+
err = fakeClient.Get(t.Context(), client.ObjectKeyFromObject(tt.kcp), &updatedKCP)
14841483
require.NoError(t, err, "Should be able to get updated KCP")
14851484

14861485
if tt.expectRolloutTriggered {

pkg/handlers/generic/lifecycle/csi/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func Test_AfterControlPlaneInitialized(t *testing.T) {
156156
}
157157
for _, tt := range tests {
158158
t.Run(tt.name, func(t *testing.T) {
159-
ctx := context.Background()
159+
ctx := t.Context()
160160
client := fake.NewClientBuilder().Build()
161161
handler := New(client, testProviderHandlers)
162162
resp := &runtimehooksv1.AfterControlPlaneInitializedResponse{}

pkg/handlers/generic/lifecycle/servicelbgc/deleter_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package servicelbgc
55

66
import (
7-
"context"
87
"testing"
98

109
"github.com/go-logr/logr"
@@ -202,14 +201,14 @@ func Test_deleteServicesWithLoadBalancer(t *testing.T) {
202201
svc := &tt.startServices[i]
203202
require.NoError(
204203
t,
205-
fakeClient.Create(context.Background(), svc),
204+
fakeClient.Create(t.Context(), svc),
206205
"error creating Service",
207206
)
208207
}
209208

210209
for {
211210
err := deleteServicesWithLoadBalancer(
212-
context.Background(),
211+
t.Context(),
213212
fakeClient,
214213
logr.Discard(),
215214
)
@@ -227,7 +226,7 @@ func Test_deleteServicesWithLoadBalancer(t *testing.T) {
227226
services := &corev1.ServiceList{}
228227
require.NoError(
229228
t,
230-
fakeClient.List(context.Background(), services),
229+
fakeClient.List(t.Context(), services),
231230
"error listing Services",
232231
)
233232
assert.Equal(t, tt.endServices, services.Items)

pkg/handlers/generic/lifecycle/serviceloadbalancer/handler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func testCases(t *testing.T) []testCase {
124124
func TestAfterControlPlaneInitialized(t *testing.T) {
125125
for _, tt := range testCases(t) {
126126
t.Run(tt.name, func(t *testing.T) {
127-
ctx := context.Background()
127+
ctx := t.Context()
128128
client := fake.NewClientBuilder().Build()
129129
handler := New(client, testProviderHandlers)
130130
resp := &runtimehooksv1.AfterControlPlaneInitializedResponse{}
@@ -157,7 +157,7 @@ func TestAfterControlPlaneInitialized(t *testing.T) {
157157
func TestBeforeClusterUpgrade(t *testing.T) {
158158
for _, tt := range testCases(t) {
159159
t.Run(tt.name, func(t *testing.T) {
160-
ctx := context.Background()
160+
ctx := t.Context()
161161
client := fake.NewClientBuilder().Build()
162162
handler := New(client, testProviderHandlers)
163163
resp := &runtimehooksv1.BeforeClusterUpgradeResponse{}

pkg/handlers/generic/mutation/controlplanevirtualip/providers/kubevip_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package providers
55

66
import (
7-
"context"
87
"testing"
98

109
"github.com/stretchr/testify/assert"
@@ -174,7 +173,7 @@ func Test_GenerateFilesAndCommands(t *testing.T) {
174173
}
175174

176175
files, preKubeadmCommands, postKubeadmCommands, err := provider.GenerateFilesAndCommands(
177-
context.Background(),
176+
t.Context(),
178177
tt.controlPlaneEndpointSpec,
179178
tt.cluster,
180179
)

pkg/handlers/generic/mutation/mirrors/inject_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package mirrors
55

66
import (
7-
"context"
87
"fmt"
98
"testing"
109

@@ -559,7 +558,7 @@ func Test_containerdConfigFromRegistryAddon(t *testing.T) {
559558
for _, tt := range tests {
560559
t.Run(tt.name, func(t *testing.T) {
561560
t.Parallel()
562-
got, err := containerdConfigFromRegistryAddon(context.Background(), tt.c, tt.cluster)
561+
got, err := containerdConfigFromRegistryAddon(t.Context(), tt.c, tt.cluster)
563562
if tt.wantErr != nil {
564563
require.EqualError(t, err, tt.wantErr.Error())
565564
} else {

0 commit comments

Comments
 (0)