summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/xenolf/lego/acme/utils_test.go
blob: 158af4116c067307c9296c41ed9b38da5ffa2698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package acme

import (
	"testing"
	"time"
)

func TestWaitForTimeout(t *testing.T) {
	c := make(chan error)
	go func() {
		err := WaitFor(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)
		}
	}
}