From 4b46ff8ce09f4aec7ed98988d151d10f91ecad46 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Thu, 15 Feb 2024 09:54:56 +0100 Subject: [PATCH] test: fix test datarace within helper broker. (#19974) --- helper/broker/notify_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helper/broker/notify_test.go b/helper/broker/notify_test.go index 69b55d808..cda4e626d 100644 --- a/helper/broker/notify_test.go +++ b/helper/broker/notify_test.go @@ -46,12 +46,12 @@ func TestGenericNotifier(t *testing.T) { var notifiedWG sync.WaitGroup for i := 0; i < 6; i++ { - go func(wg *sync.WaitGroup) { - wg.Add(1) + notifiedWG.Add(1) + go func() { + defer notifiedWG.Done() msg := notifier.WaitForChange(3 * time.Second) require.Equal(t, "we got an update and not a timeout", msg) - wg.Done() - }(¬ifiedWG) + }() } // Ensure the routines have had time to start before sending the notify