Skip to content

Commit 041723b

Browse files
committed
Fix broken TestCACacheVerify test
Parallel test closures execute in a goroutine, possibly after the next loop iteration has already began. As a result, the loop var they capture changes before the test execute, leading to all of them executing just the last test in the map. This fixes that by making the closure capture local variables rather than the loop variables See similar main kubernetes repo PR kubernetes/kubernetes#111846
1 parent 1533c13 commit 041723b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmd/gcp-controller-manager/ca_cache_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func TestCACacheVerify(t *testing.T) {
4141
}
4242
})
4343
for desc, invalidCert := range ca.invalidCerts {
44+
desc := desc
45+
invalidCert := invalidCert
4446
t.Run(desc, func(t *testing.T) {
4547
t.Parallel()
4648
if err := c.verify(invalidCert); err == nil {

0 commit comments

Comments
 (0)