|
6 | 6 | "regexp" |
7 | 7 | "strconv" |
8 | 8 | "strings" |
| 9 | + "sync" |
9 | 10 | "testing" |
10 | 11 |
|
11 | 12 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
@@ -53,7 +54,7 @@ func TestValidateFormType(t *testing.T) { |
53 | 54 | // formTypesChecked keeps track of all checks run. It will be used to |
54 | 55 | // ensure all combinations of form_type and option_type are tested. |
55 | 56 | // All untested options are assumed to throw an error. |
56 | | - formTypesChecked := make(map[string]struct{}) |
| 57 | + var formTypesChecked sync.Map |
57 | 58 |
|
58 | 59 | expectType := func(expected provider.ParameterFormType, opts formTypeCheck) formTypeTestCase { |
59 | 60 | ftname := opts.formType |
@@ -240,12 +241,12 @@ func TestValidateFormType(t *testing.T) { |
240 | 241 | for _, c := range cases { |
241 | 242 | t.Run(c.name, func(t *testing.T) { |
242 | 243 | t.Parallel() |
243 | | - if _, ok := formTypesChecked[c.config.String()]; ok { |
| 244 | + if _, ok := formTypesChecked.Load(c.config.String()); ok { |
244 | 245 | t.Log("Duplicated form type check, delete this extra test case") |
245 | 246 | t.Fatalf("form type %q already checked", c.config.String()) |
246 | 247 | } |
247 | 248 |
|
248 | | - formTypesChecked[c.config.String()] = struct{}{} |
| 249 | + formTypesChecked.Store(c.config.String(), struct{}{}) |
249 | 250 | formTypeTest(t, c) |
250 | 251 | }) |
251 | 252 | } |
@@ -282,7 +283,7 @@ func TestValidateFormType(t *testing.T) { |
282 | 283 | } |
283 | 284 |
|
284 | 285 | for _, check := range requiredChecks { |
285 | | - if _, alreadyChecked := formTypesChecked[check.String()]; alreadyChecked { |
| 286 | + if _, alreadyChecked := formTypesChecked.Load(check.String()); alreadyChecked { |
286 | 287 | continue |
287 | 288 | } |
288 | 289 |
|
|
0 commit comments