Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/util/chan.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package util

func ChanSendEmpty[T any](ch chan T, count int) {
for range count {
var val T
ch <- val
}
for i := 0; i < count; i++ {
var val T
ch <- val
}
}

func ChanClose[T any](ch ...chan T) {
Expand Down
18 changes: 9 additions & 9 deletions internal/util/chan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func TestChanSendEmpty(t *testing.T) {

// Check if the correct number of values were sent
received := 0
for range tt.count {
select {
case <-ch:
received++
case <-time.After(100 * time.Millisecond):
t.Errorf("Timeout waiting for value")
return
}
}
for i := 0; i < tt.count; i++ {
select {
case <-ch:
received++
case <-time.After(100 * time.Millisecond):
t.Errorf("Timeout waiting for value")
return
}
}

if received != tt.expected {
t.Errorf("ChanSendEmpty() sent %v values; want %v", received, tt.expected)
Expand Down
Loading