From 33a7add74539116f736e894caedc1f409023e130 Mon Sep 17 00:00:00 2001 From: Simon Richardson Date: Wed, 13 Jul 2022 15:15:13 +0100 Subject: [PATCH] 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. --- label/storage_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/label/storage_test.go b/label/storage_test.go index a941a7e6dc..653413a1fc 100644 --- a/label/storage_test.go +++ b/label/storage_test.go @@ -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()