lego/platform/wait/wait_test.go

27 lines
472 B
Go
Raw Normal View History

package wait // import "github.com/xenolf/lego/platform/wait"
import (
"testing"
"time"
)
func TestForTimeout(t *testing.T) {
c := make(chan error)
go func() {
2018-12-21 23:53:05 +00:00
err := For("", 3*time.Second, 1*time.Second, func() (bool, error) {
return false, nil
})
c <- err
}()
timeout := time.After(4 * time.Second)
select {
case <-timeout:
t.Fatal("timeout exceeded")
case err := <-c:
if err == nil {
t.Errorf("expected timeout error; got %v", err)
}
}
}