mirror of https://github.com/spf13/viper.git
test(windows): fix watch file test
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
552e3bd0ca
commit
15c88da25c
|
@ -2346,10 +2346,13 @@ 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")
|
||||
wgDoneOnce.Do(func() {
|
||||
wg.Done()
|
||||
})
|
||||
})
|
||||
v.WatchConfig()
|
||||
// when overwriting the file and waiting for the custom change notification handler to be triggered
|
||||
err = ioutil.WriteFile(configFile, []byte("foo: baz\n"), 0640)
|
||||
|
|
Loading…
Reference in New Issue