test(windows): fix watch file test

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Mark Sagi-Kazar 2021-09-22 10:39:19 +02:00 committed by Márk Sági-Kazár
parent 552e3bd0ca
commit 15c88da25c
1 changed files with 4 additions and 1 deletions

View File

@ -2346,9 +2346,12 @@ func TestWatchFile(t *testing.T) {
t.Logf("test config file: %s\n", configFile)
wg := sync.WaitGroup{}
wg.Add(1)
var wgDoneOnce sync.Once // OnConfigChange is called twice on Windows
v.OnConfigChange(func(in fsnotify.Event) {
t.Logf("config file changed")
wg.Done()
wgDoneOnce.Do(func() {
wg.Done()
})
})
v.WatchConfig()
// when overwriting the file and waiting for the custom change notification handler to be triggered