Move ChannelReceivesSomething to tests package.

ChannelReceivesSomething (formerly WaitForChannel) originally was
located in the helpers package.
This move was done to remove a cyclic dependency with the nomand package.
This commit is contained in:
Konrad Hanff
2021-06-21 08:32:44 +02:00
parent 92f1af83ae
commit c7ed54942d
3 changed files with 25 additions and 25 deletions

14
tests/util.go Normal file
View File

@ -0,0 +1,14 @@
package tests
import "time"
// ChannelReceivesSomething waits timeout seconds for something to be received from channel ch.
// If something is received, it returns true. If the timeout expires without receiving anything, it return false.
func ChannelReceivesSomething(ch chan bool, timeout time.Duration) bool {
select {
case <-ch:
return true
case <-time.After(timeout):
return false
}
}