Skip to content

Commit ecc5584

Browse files
authored
fix(tests): improve handling of multiple fsnotify events in Windows tests (#541)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
1 parent e694e4a commit ecc5584

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/kubernetes/provider_watch_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,16 @@ func (s *ProviderWatchTargetsTestSuite) TestKubeConfigClusterProvider() {
103103
})
104104

105105
s.Run("Keeps watching for further changes", func() {
106-
s.kubeconfig.CurrentContext = "context-2"
107-
s.Require().NoError(clientcmd.WriteToFile(*s.kubeconfig, s.staticConfig.KubeConfig))
106+
kubeconfig := *s.kubeconfig
107+
kubeconfig.CurrentContext = "context-2"
108+
s.Require().NoError(clientcmd.WriteToFile(kubeconfig, s.staticConfig.KubeConfig))
108109
s.Require().NoError(waitForCallback(5 * time.Second))
109110

110111
s.Run("Replaces default target with new context", func() {
112+
// In Windows systems, fsnotify may trigger multiple events for a single file change,
113+
s.Require().NoError(test.WaitForCondition(5*time.Second, func() bool {
114+
return provider.GetDefaultTarget() == "context-2"
115+
}))
111116
s.Equal("context-2", provider.GetDefaultTarget(), "Expected default target context to be updated")
112117
})
113118
})

0 commit comments

Comments
 (0)