From 53563ab498cc157d74e2178f89c613fd9c4ac74c Mon Sep 17 00:00:00 2001 From: letian Date: Wed, 15 Sep 2021 21:05:17 +0800 Subject: [PATCH] fix error in file test (#1483) --- config/file/file_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/file/file_test.go b/config/file/file_test.go index 383c2e185..d485e1f8d 100644 --- a/config/file/file_test.go +++ b/config/file/file_test.go @@ -299,11 +299,14 @@ func TestMergeDataRace(t *testing.T) { c := config.New(config.WithSource( NewSource(path), )) + const count = 80 wg := &sync.WaitGroup{} wg.Add(2) + startCh := make(chan struct{}) go func() { defer wg.Done() - for i := 0; i < 100; i++ { + <-startCh + for i := 0; i < count; i++ { var conf struct{} if err := c.Scan(&conf); err != nil { t.Error(err) @@ -313,11 +316,13 @@ func TestMergeDataRace(t *testing.T) { go func() { defer wg.Done() - for i := 0; i < 100; i++ { + <-startCh + for i := 0; i < count; i++ { if err := c.Load(); err != nil { t.Error(err) } } }() + close(startCh) wg.Wait() }