test(label): Invalid closure capture (#23353)

Whilst working on cloud labels, I noticed that the label storage test
isn't correctly capturing the testScenario. This is because t.Parallel()
is in use, so only the "delete" scenario will only ever be tested.

The following changes fix that, by capturing the testScenario in a local
variable so that the test function can use that correctly.

As a drive-by, I fixed the error referencing the wrong expectation.
pull/23542/head
Simon Richardson 2022-07-13 15:15:13 +01:00 committed by GitHub
parent 4b2949a67a
commit 33a7add745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -221,13 +221,14 @@ func TestLabels(t *testing.T) {
}
if len(l) != 9 {
t.Fatalf("expected 2 labels, got: %d", len(l))
t.Fatalf("expected 9 labels, got: %d", len(l))
}
},
},
}
for _, testScenario := range tt {
for _, ts := range tt {
testScenario := ts
t.Run(testScenario.name, func(t *testing.T) {
t.Parallel()