lego/platform/wait/wait_test.go

26 lines
410 B
Go
Raw Normal View History

2019-03-11 16:56:48 +00:00
package wait
import (
"testing"
"time"
)
func TestForTimeout(t *testing.T) {
c := make(chan error)
go func() {
2020-12-09 19:52:21 +00:00
c <- For("", 3*time.Second, 1*time.Second, func() (bool, error) {
return false, nil
})
}()
2020-12-09 19:52:21 +00:00
timeout := time.After(5 * time.Second)
select {
case <-timeout:
t.Fatal("timeout exceeded")
case err := <-c:
if err == nil {
t.Errorf("expected timeout error; got %v", err)
}
}
}