test: fix test datarace within helper broker. (#19974)

This commit is contained in:
James Rasell
2024-02-15 09:54:56 +01:00
committed by GitHub
parent e4648551e5
commit 4b46ff8ce0

View File

@@ -46,12 +46,12 @@ func TestGenericNotifier(t *testing.T) {
var notifiedWG sync.WaitGroup var notifiedWG sync.WaitGroup
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
go func(wg *sync.WaitGroup) { notifiedWG.Add(1)
wg.Add(1) go func() {
defer notifiedWG.Done()
msg := notifier.WaitForChange(3 * time.Second) msg := notifier.WaitForChange(3 * time.Second)
require.Equal(t, "we got an update and not a timeout", msg) require.Equal(t, "we got an update and not a timeout", msg)
wg.Done() }()
}(&notifiedWG)
} }
// Ensure the routines have had time to start before sending the notify // Ensure the routines have had time to start before sending the notify