fix error in file test (#1483)

pull/1488/head
letian 3 years ago committed by GitHub
parent 894fc1a058
commit 53563ab498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      config/file/file_test.go

@ -299,11 +299,14 @@ func TestMergeDataRace(t *testing.T) {
c := config.New(config.WithSource( c := config.New(config.WithSource(
NewSource(path), NewSource(path),
)) ))
const count = 80
wg := &sync.WaitGroup{} wg := &sync.WaitGroup{}
wg.Add(2) wg.Add(2)
startCh := make(chan struct{})
go func() { go func() {
defer wg.Done() defer wg.Done()
for i := 0; i < 100; i++ { <-startCh
for i := 0; i < count; i++ {
var conf struct{} var conf struct{}
if err := c.Scan(&conf); err != nil { if err := c.Scan(&conf); err != nil {
t.Error(err) t.Error(err)
@ -313,11 +316,13 @@ func TestMergeDataRace(t *testing.T) {
go func() { go func() {
defer wg.Done() defer wg.Done()
for i := 0; i < 100; i++ { <-startCh
for i := 0; i < count; i++ {
if err := c.Load(); err != nil { if err := c.Load(); err != nil {
t.Error(err) t.Error(err)
} }
} }
}() }()
close(startCh)
wg.Wait() wg.Wait()
} }

Loading…
Cancel
Save