Skip to content

Commit

Permalink
test: Remove loop variable rebinding (#7587)
Browse files Browse the repository at this point in the history
[Gopls](golang/go#66876) had a recent update
which fixed my text editor from complaining about the "loop variable
being captured by func literal".

Fixes #7454
  • Loading branch information
pgporada authored Jul 12, 2024
1 parent f79c344 commit ebb5299
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 24 deletions.
9 changes: 0 additions & 9 deletions ca/ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ func TestIssuePrecertificate(t *testing.T) {
}

for _, testCase := range testCases {
// TODO(#7454) Remove this rebinding
testCase := testCase

// The loop through the issuance modes must be inside the loop through
// |testCases| because the "certificate-for-precertificate" tests use
// the precertificates previously generated from the preceding
Expand Down Expand Up @@ -697,8 +694,6 @@ func TestProfiles(t *testing.T) {
}

for _, tc := range testCases {
// TODO(#7454) Remove this rebinding
tc := tc
// This is handled by boulder-ca, not the CA package.
if tc.defaultName == "" {
tc.defaultName = testCtx.defaultCertProfileName
Expand Down Expand Up @@ -809,8 +804,6 @@ func TestInvalidCSRs(t *testing.T) {
}

for _, testCase := range testCases {
// TODO(#7454) Remove this rebinding
testCase := testCase
testCtx := setup(t)
sa := &mockSA{}
ca, err := NewCertificateAuthorityImpl(
Expand Down Expand Up @@ -1319,8 +1312,6 @@ func TestVerifyTBSCertIsDeterministic(t *testing.T) {
}

for _, testCase := range testCases {
// TODO(#7454) Remove this rebinding
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
err := tbsCertIsDeterministic(testCase.lintCertBytes, testCase.leafCertBytes)
Expand Down
1 change: 0 additions & 1 deletion crl/idp/idp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestMakeUserCertsExt(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got, err := MakeUserCertsExt(tc.urls)
Expand Down
1 change: 0 additions & 1 deletion issuance/crl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestNewCRLProfile(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
actual, err := NewCRLProfile(tc.config)
Expand Down
3 changes: 0 additions & 3 deletions issuance/issuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func TestLoadCertificate(t *testing.T) {
{"happy path", "../test/hierarchy/int-e1.cert.pem", ""},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
_, err := LoadCertificate(tc.path)
Expand Down Expand Up @@ -122,7 +121,6 @@ func TestLoadSigner(t *testing.T) {
// keys in it don't match the fakeKey we generated above.
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
_, err := loadSigner(tc.loc, fakeKey.Public())
Expand Down Expand Up @@ -180,7 +178,6 @@ func TestNewIssuerKeyUsage(t *testing.T) {
{"all three", x509.KeyUsageCertSign | x509.KeyUsageCRLSign | x509.KeyUsageDigitalSignature, ""},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
_, err := newIssuer(
Expand Down
4 changes: 2 additions & 2 deletions linter/lints/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package lints
import (
"testing"

"github.com/letsencrypt/boulder/test"
"golang.org/x/crypto/cryptobyte"
"golang.org/x/crypto/cryptobyte/asn1"

"github.com/letsencrypt/boulder/test"
)

var onlyContainsUserCertsTag = asn1.Tag(1).ContextSpecific()
Expand Down Expand Up @@ -78,7 +79,6 @@ func TestReadOptionalASN1BooleanWithTag(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion ratelimits/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func TestValidateIdForName(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("%s/%s", tc.limit, tc.desc), func(t *testing.T) {
t.Parallel()
err := validateIdForName(tc.limit, tc.id)
Expand Down
1 change: 0 additions & 1 deletion test/integration/bad_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestFermat(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 0 additions & 6 deletions va/caa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,6 @@ func TestAccountURIMatches(t *testing.T) {
}

for _, tc := range tests {
// TODO(#7454) Remove this rebinding
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got := caaAccountURIMatches(tc.params, tc.prefixes, tc.id)
Expand Down Expand Up @@ -1387,8 +1385,6 @@ func TestValidationMethodMatches(t *testing.T) {
}

for _, tc := range tests {
// TODO(#7454) Remove this rebinding
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got := caaValidationMethodMatches(tc.params, tc.method)
Expand Down Expand Up @@ -1539,8 +1535,6 @@ func TestExtractIssuerDomainAndParameters(t *testing.T) {
},
}
for _, tc := range tests {
// TODO(#7454) Remove this rebinding
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
gotDomain, gotParameters, gotErr := parseCAARecord(&dns.CAA{Value: tc.value})
Expand Down

0 comments on commit ebb5299

Please sign in to comment.