From 87e736d0f6d527ba7df20de8bb5977b70f2897a3 Mon Sep 17 00:00:00 2001 From: Ola <1386739+olahol@users.noreply.github.com> Date: Wed, 6 Mar 2024 12:31:16 +0100 Subject: [PATCH] Fix test data race --- melody_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/melody_test.go b/melody_test.go index e256272..057b2e0 100644 --- a/melody_test.go +++ b/melody_test.go @@ -10,6 +10,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "testing" "testing/quick" "time" @@ -790,9 +791,9 @@ func TestConcurrentMessageHandling(t *testing.T) { ws.m.Config.ConcurrentMessageHandling = cmh ws.m.Config.PongWait = base - var errorSet bool + var errorSet atomic.Bool ws.m.HandleError(func(s *Session, err error) { - errorSet = true + errorSet.Store(true) done <- struct{}{} }) @@ -811,7 +812,7 @@ func TestConcurrentMessageHandling(t *testing.T) { <-done - return errorSet + return errorSet.Load() } t.Run("text should error", func(t *testing.T) {