Skip to content

Commit

Permalink
add test for nil callback in stream
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Nov 12, 2023
1 parent b528efd commit b7b9417
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ func TestStream(t *testing.T) {
require.Equal(t, []int{0, 2, 4, 6, 8}, res)
})

t.Run("nil callback", func(t *testing.T) {
t.Parallel()
s := stream.New()
var totalCount atomic.Int64
for i := 0; i < 5; i++ {
s.Go(func() stream.Callback {
totalCount.Add(1)
return nil
})
}
s.Wait()
require.Equal(t, int64(5), totalCount.Load())
})

t.Run("max goroutines", func(t *testing.T) {
t.Parallel()
s := stream.New().WithMaxGoroutines(5)
Expand Down

0 comments on commit b7b9417

Please sign in to comment.