Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Jun 11, 2024
1 parent 8d0c756 commit 245bd17
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions events/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,27 @@ func TestSimpleSubscribersDontRecieveItemsAfterUnsubscribing(t *testing.T) {
// closing the channel will result in reads yielding the default value
assert.Equal(t, 0, <-ch)
}
func TestSimpleEachSubscribersRecievesEachItemGivenBufferedEventChan2(t *testing.T) {
c := NewSimpleChannel[Update](10000000, 5)
for i := 0; i < 1000; i++ {
sub, err := c.Subscribe()
if err != nil {
panic(err)
}
defer c.Unsubscribe(sub)
go handleChannelMessages(sub)
}
for i := 0; i < 100; i++ {
c.Publish(
Update{
DocID: "test",
},
)
}
}
func handleChannelMessages(sub Subscription[Update]) {
for msg := range sub {
_ = msg
time.Sleep(100 * time.Millisecond)
}
}

0 comments on commit 245bd17

Please sign in to comment.