Skip to content

Commit

Permalink
Merge pull request #863 from strukturag/redefine-builtin-max
Browse files Browse the repository at this point in the history
Don't redefine built-in id "max".
  • Loading branch information
fancycode authored Nov 11, 2024
2 parents 119b1ff + c642319 commit b7c40d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions natsclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func testNatsClient_Subscribe(t *testing.T, client NatsClient) {
ch := make(chan struct{})

var received atomic.Int32
max := int32(20)
maxPublish := int32(20)
ready := make(chan struct{})
quit := make(chan struct{})
defer close(quit)
Expand All @@ -74,7 +74,7 @@ func testNatsClient_Subscribe(t *testing.T, client NatsClient) {
select {
case <-dest:
total := received.Add(1)
if total == max {
if total == maxPublish {
if err := sub.Unsubscribe(); !assert.NoError(err) {
return
}
Expand All @@ -86,15 +86,15 @@ func testNatsClient_Subscribe(t *testing.T, client NatsClient) {
}
}()
<-ready
for i := int32(0); i < max; i++ {
for i := int32(0); i < maxPublish; i++ {
assert.NoError(client.Publish("foo", []byte("hello")))

// Allow NATS goroutines to process messages.
time.Sleep(10 * time.Millisecond)
}
<-ch

require.EqualValues(max, received.Load(), "Received wrong # of messages")
require.EqualValues(maxPublish, received.Load(), "Received wrong # of messages")
}

func TestNatsClient_Subscribe(t *testing.T) {
Expand Down

0 comments on commit b7c40d1

Please sign in to comment.