From 15c88da25c93aa267529e52c973290e1fd0b6aea Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 22 Sep 2021 10:39:19 +0200 Subject: [PATCH] test(windows): fix watch file test Signed-off-by: Mark Sagi-Kazar --- viper_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/viper_test.go b/viper_test.go index 2ad25ba..349d09e 100644 --- a/viper_test.go +++ b/viper_test.go @@ -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