Skip to content

Commit

Permalink
Fix race condition in subscriber test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Kananykhin committed Mar 21, 2024
1 parent c7b1018 commit 87df8e3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions queryer/subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
)

func TestSubscribe(t *testing.T) {
var called int
var called int32
testFn := func() {
called += 1
atomic.AddInt32(&called, 1)
}

s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestSubscribe(t *testing.T) {
assert.FailNow(t, "timeout")
}
closeCh <- struct{}{}
assert.Equal(t, 2, called)
assert.EqualValues(t, 2, atomic.LoadInt32(&called))
}

func TestSubscribeErrorQuery(t *testing.T) {
Expand Down Expand Up @@ -224,7 +224,6 @@ func TestSubscribeErrorQuery(t *testing.T) {
func TestSubscribeErrorNoSupportForWs(t *testing.T) {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
return

}))
defer s.Close()

Expand Down

0 comments on commit 87df8e3

Please sign in to comment.