Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21147bf

Browse files
authored
test: fix concurrent map write of TestValidateFormType (#390)
1 parent5648efb commit21147bf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎provider/formtype_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"regexp"
77
"strconv"
88
"strings"
9+
"sync"
910
"testing"
1011

1112
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -53,7 +54,7 @@ func TestValidateFormType(t *testing.T) {
5354
// formTypesChecked keeps track of all checks run. It will be used to
5455
// ensure all combinations of form_type and option_type are tested.
5556
// All untested options are assumed to throw an error.
56-
formTypesChecked:=make(map[string]struct{})
57+
varformTypesCheckedsync.Map
5758

5859
expectType:=func(expected provider.ParameterFormType,optsformTypeCheck)formTypeTestCase {
5960
ftname:=opts.formType
@@ -240,12 +241,12 @@ func TestValidateFormType(t *testing.T) {
240241
for_,c:=rangecases {
241242
t.Run(c.name,func(t*testing.T) {
242243
t.Parallel()
243-
if_,ok:=formTypesChecked[c.config.String()];ok {
244+
if_,ok:=formTypesChecked.Load(c.config.String());ok {
244245
t.Log("Duplicated form type check, delete this extra test case")
245246
t.Fatalf("form type %q already checked",c.config.String())
246247
}
247248

248-
formTypesChecked[c.config.String()]=struct{}{}
249+
formTypesChecked.Store(c.config.String(),struct{}{})
249250
formTypeTest(t,c)
250251
})
251252
}
@@ -282,7 +283,7 @@ func TestValidateFormType(t *testing.T) {
282283
}
283284

284285
for_,check:=rangerequiredChecks {
285-
if_,alreadyChecked:=formTypesChecked[check.String()];alreadyChecked {
286+
if_,alreadyChecked:=formTypesChecked.Load(check.String());alreadyChecked {
286287
continue
287288
}
288289

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp