File: wait_test.go

package info (click to toggle)
golang-github-xenolf-lego 4.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,080 kB
  • sloc: xml: 533; makefile: 128; sh: 18
file content (26 lines) | stat: -rw-r--r-- 430 bytes parent folder | download | duplicates (2)
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 wait

import (
	"testing"
	"time"
)

func TestForTimeout(t *testing.T) {
	c := make(chan error)
	go func() {
		c <- For("", 3*time.Second, 1*time.Second, func() (bool, error) {
			return false, nil
		})
	}()

	timeout := time.After(6 * time.Second)
	select {
	case <-timeout:
		t.Fatal("timeout exceeded")
	case err := <-c:
		if err == nil {
			t.Errorf("expected timeout error; got %v", err)
		}
		t.Logf("%v", err)
	}
}