Skip to content

Commit

Permalink
Fix test data race
Browse files Browse the repository at this point in the history
  • Loading branch information
olahol committed Mar 6, 2024
1 parent f3ccd79 commit 87e736d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions melody_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"testing"
"testing/quick"
"time"
Expand Down Expand Up @@ -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{}{}
})

Expand All @@ -811,7 +812,7 @@ func TestConcurrentMessageHandling(t *testing.T) {

<-done

return errorSet
return errorSet.Load()
}

t.Run("text should error", func(t *testing.T) {
Expand Down

0 comments on commit 87e736d

Please sign in to comment.