gopenfusion/internal/testutil/helpers.go
CPunch 1f63f9856e testutil: refactoring/organizing
split helpers.go into env.go && dummy.go
2024-03-03 13:11:37 -06:00

26 lines
399 B
Go

package testutil
import (
"sync"
"time"
)
func SelectWithTimeout(ch <-chan struct{}, timeout time.Duration) bool {
select {
case <-ch:
return true
case <-time.After(timeout):
return false
}
}
func WaitWithTimeout(wg *sync.WaitGroup, timeout time.Duration) bool {
done := make(chan struct{})
go func() {
defer close(done)
wg.Wait()
}()
return SelectWithTimeout(done, timeout)
}