Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tejzpr committed Mar 12, 2021
1 parent 0932e51 commit 8fd02a1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,42 @@ func Test(t *testing.T) {
}
t.Log("Test with Default Pool Size Completed")
})
t.Run("Test channel based closers", func(t *testing.T) {
max := 10
inputChan := make(chan *OrderedInput)
doneChan := make(chan bool)
outChan := Process(inputChan, workFn, &Options{OutChannelBuffer: 2})
go func(t *testing.T) {
counter := 0
for {
select {
case out, chok := <-outChan:
if chok {
if _, ok := out.Value.(int); !ok {
t.Error("Invalid output")
} else {
counter++
}
} else {
if counter != max {
t.Error("Input count does not match output count")
}
doneChan <- true
}
}
}
}(t)

// Create work and the associated order
for work := 0; work < max; work++ {

input := &OrderedInput{work}
inputChan <- input
}
close(inputChan)
<-doneChan
t.Log("Test channel based closers Completed")
})
t.Run("Test Zero Load", func(t *testing.T) {
max := 10
inputChan := make(chan *OrderedInput)
Expand Down

0 comments on commit 8fd02a1

Please sign in to comment.