Enable 'copyloopvar' linter

This commit is contained in:
Joshua Casey
2024-05-10 12:51:02 -05:00
parent e04e5e0185
commit 7b36c8ab54
115 changed files with 83 additions and 274 deletions
-2
View File
@@ -73,7 +73,6 @@ func TestCLIGetKubeconfigStaticToken_Parallel(t *testing.T) {
testlib.AccessAsUserWithKubectlTest(stdout, env.TestUser.ExpectedUsername, env.ConciergeNamespace),
)
for _, group := range env.TestUser.ExpectedGroups {
group := group
t.Run(
"access as group "+group+" with kubectl",
testlib.AccessAsGroupWithKubectlTest(stdout, group, env.ConciergeNamespace),
@@ -86,7 +85,6 @@ func TestCLIGetKubeconfigStaticToken_Parallel(t *testing.T) {
// Validate that we can auth to the API via our user.
t.Run("access as user with client-go", testlib.AccessAsUserTest(ctx, env.TestUser.ExpectedUsername, kubeClient))
for _, group := range env.TestUser.ExpectedGroups {
group := group
t.Run("access as group "+group+" with client-go", testlib.AccessAsGroupTest(ctx, group, kubeClient))
}
@@ -72,7 +72,6 @@ func TestAPIServingCertificateAutoCreationAndRotation_Disruptive(t *testing.T) {
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
kubeClient := testlib.NewKubernetesClientset(t)
aggregatedClient := testlib.NewAggregatedClientset(t)
@@ -94,7 +94,6 @@ func TestSuccessfulCredentialRequest_Browser(t *testing.T) {
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
authenticator := test.authenticator(ctx, t)
token, username, groups := test.token(t)
@@ -132,7 +131,6 @@ func TestSuccessfulCredentialRequest_Browser(t *testing.T) {
testlib.AccessAsUserTest(ctx, username, clientWithCertFromCredentialRequest),
)
for _, group := range groups {
group := group
t.Run(
"access as group "+group,
testlib.AccessAsGroupTest(ctx, group, clientWithCertFromCredentialRequest),
@@ -328,7 +328,6 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl
testlib.AccessAsUserTest(ctx, env.TestUser.ExpectedUsername, impersonationProxyKubeClient(t)),
)
for _, group := range env.TestUser.ExpectedGroups {
group := group
t.Run(
"access as group "+group,
testlib.AccessAsGroupTest(ctx, group, impersonationProxyKubeClient(t)),
@@ -2042,8 +2041,6 @@ func ensureDNSResolves(t *testing.T, urlString string) {
defer cancel()
for _, resolver := range []*net.Resolver{goResolver, notGoResolver} {
resolver := resolver
ips, ipErr := resolver.LookupIPAddr(ctx, host)
requireEventually.NoError(ipErr)
requireEventually.NotEmpty(ips)
+1 -2
View File
@@ -463,10 +463,9 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr
})
for _, tt := range tests {
tt := tt
t.Run(tt.group.Name, func(t *testing.T) {
t.Parallel()
require.Contains(t, groups, &tt.group)
require.Contains(t, groups, tt.group.DeepCopy())
for groupVersion, expectedResources := range tt.resourceByVersion {
// Find the actual resource list and make a copy.
-5
View File
@@ -182,7 +182,6 @@ func leaderElectionClients(t *testing.T, namespace *corev1.Namespace, leaseName
func pickRandomLeaderElectionClient(clients map[string]*kubeclient.Client) *kubeclient.Client {
for _, client := range clients {
client := client
return client
}
panic("clients map was empty")
@@ -223,8 +222,6 @@ func runWriteRequests(ctx context.Context, clients map[string]*kubeclient.Client
out := make(map[string]error, len(clients))
for identity, client := range clients {
identity, client := identity, client
out[identity] = runWriteRequest(ctx, client)
}
@@ -246,8 +243,6 @@ func checkOnlyLeaderCanWrite(ctx context.Context, t *testing.T, namespace *corev
testlib.RequireEventually(t, func(requireEventually *require.Assertions) {
var leaders, nonLeaders int
for identity, err := range runWriteRequests(ctx, clients) {
identity, err := identity, err
if identity == *lease.Spec.HolderIdentity {
leaders++
requireEventually.NoError(err, "leader client %q should have no error", identity)
+1 -6
View File
@@ -1,4 +1,4 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package integration
@@ -39,8 +39,6 @@ func splitIntegrationTestsIntoBuckets(m *testing.M) {
var serialTests, parallelTests, disruptiveTests, finalTests []testing.InternalTest
for _, test := range tests {
test := test
// top level integration tests the end with the string _Parallel
// are indicating that they are safe to run in parallel with
// other serial tests (which Go does not let you easily express).
@@ -69,7 +67,6 @@ func splitIntegrationTestsIntoBuckets(m *testing.M) {
t.Parallel() // outer test always runs in parallel for this bucket
for _, test := range serialTests {
test := test
t.Run(test.Name, func(t *testing.T) {
test.F(t) // inner serial tests do not run in parallel
})
@@ -84,7 +81,6 @@ func splitIntegrationTestsIntoBuckets(m *testing.M) {
t.Parallel() // outer test always runs in parallel for this bucket
for _, test := range parallelTests {
test := test
t.Run(test.Name, func(t *testing.T) {
t.Parallel() // inner parallel tests do run in parallel
@@ -101,7 +97,6 @@ func splitIntegrationTestsIntoBuckets(m *testing.M) {
// outer test never runs in parallel for this bucket
for _, test := range disruptiveTests {
test := test
t.Run(test.Name, func(t *testing.T) {
test.F(t) // inner disruptive tests do not run in parallel
})
-1
View File
@@ -128,7 +128,6 @@ func TestSecureTLSSupervisor(t *testing.T) {
defaultECDSAOnly := ptls.Default(nil)
ciphers := make([]uint16, 0, len(defaultECDSAOnly.CipherSuites)/2)
for _, id := range defaultECDSAOnly.CipherSuites {
id := id
if !strings.Contains(tls.CipherSuiteName(id), "_ECDSA_") {
continue
}
@@ -1,4 +1,4 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package integration
@@ -73,7 +73,6 @@ func TestSupervisorOIDCDiscovery_Disruptive(t *testing.T) {
}
for _, test := range tests {
test := test
t.Run(test.Name, func(t *testing.T) {
scheme := test.Scheme
addr := test.Address
@@ -398,7 +398,6 @@ func TestOIDCClientStaticValidation_Parallel(t *testing.T) {
require.Len(t, statusErr.ErrStatus.Details.Causes, 4)
out := make([]string, 0, len(statusErr.ErrStatus.Details.Causes))
for _, cause := range statusErr.ErrStatus.Details.Causes {
cause := cause
out = append(out, fmt.Sprintf("%s: %s", cause.Field, cause.Message))
}
sort.Strings(out)
@@ -486,7 +485,6 @@ func TestOIDCClientStaticValidation_Parallel(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if tt.skip {
t.Skip()
@@ -688,7 +686,6 @@ func TestOIDCClientControllerValidations_Parallel(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
@@ -1,4 +1,4 @@
// Copyright 2022-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2022-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package integration
@@ -207,8 +207,6 @@ func TestKubectlOIDCClientSecretRequest_Parallel(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), 13*time.Minute)
@@ -873,8 +871,6 @@ func TestCreateOIDCClientSecretRequest_Parallel(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), 13*time.Minute)
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package integration
@@ -78,7 +78,6 @@ func TestSupervisorSecrets_Parallel(t *testing.T) {
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
// Ensure a secret is created with the FederationDomain's JWKS.
var updatedFederationDomain *configv1alpha1.FederationDomain