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:
14
tests/util.go
Normal file
14
tests/util.go
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user