Fix test data race
This commit is contained in:
+4
-3
@@ -10,6 +10,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"testing/quick"
|
"testing/quick"
|
||||||
"time"
|
"time"
|
||||||
@@ -790,9 +791,9 @@ func TestConcurrentMessageHandling(t *testing.T) {
|
|||||||
ws.m.Config.ConcurrentMessageHandling = cmh
|
ws.m.Config.ConcurrentMessageHandling = cmh
|
||||||
ws.m.Config.PongWait = base
|
ws.m.Config.PongWait = base
|
||||||
|
|
||||||
var errorSet bool
|
var errorSet atomic.Bool
|
||||||
ws.m.HandleError(func(s *Session, err error) {
|
ws.m.HandleError(func(s *Session, err error) {
|
||||||
errorSet = true
|
errorSet.Store(true)
|
||||||
done <- struct{}{}
|
done <- struct{}{}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -811,7 +812,7 @@ func TestConcurrentMessageHandling(t *testing.T) {
|
|||||||
|
|
||||||
<-done
|
<-done
|
||||||
|
|
||||||
return errorSet
|
return errorSet.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("text should error", func(t *testing.T) {
|
t.Run("text should error", func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user