From fdb4953eaa453f6a398d828aee1ac4adaf658561 Mon Sep 17 00:00:00 2001 From: Matthew F Leader Date: Fri, 26 Jan 2024 16:33:16 -0500 Subject: [PATCH] another range local variable --- schema/bool_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/schema/bool_test.go b/schema/bool_test.go index bca40e0..046f6de 100644 --- a/schema/bool_test.go +++ b/schema/bool_test.go @@ -152,17 +152,22 @@ var boolTestSerializationCases = map[string]struct { func TestBoolSerializationCycle(t *testing.T) { for name, tc := range boolTestSerializationCases { + // The call to t.Parallel() means that referencing the tc + // from the outer scope won't produce the proper value, so + // we need to place it in a variable, localTC, scoped inside + // the loop body. + localTC := tc t.Run(name, func(t *testing.T) { var boolType schema.Bool = schema.NewBoolSchema() - output, err := boolType.Unserialize(tc.input) + output, err := boolType.Unserialize(localTC.input) if err != nil { - if tc.expectedError { + if localTC.expectedError { return } - t.Fatalf("Failed to unserialize %v: %v", tc.input, err) + t.Fatalf("Failed to unserialize %v: %v", localTC.input, err) } - if output != tc.output { - t.Fatalf("Unexpected unserialize output for %v: %v", tc.input, output) + if output != localTC.output { + t.Fatalf("Unexpected unserialize output for %v: %v", localTC.input, output) } if err := boolType.Validate(output); err != nil {