aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/net/http2/http2_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/net/http2/http2_test.go')
-rw-r--r--vendor/golang.org/x/net/http2/http2_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/golang.org/x/net/http2/http2_test.go b/vendor/golang.org/x/net/http2/http2_test.go
index 5248776..667db48 100644
--- a/vendor/golang.org/x/net/http2/http2_test.go
+++ b/vendor/golang.org/x/net/http2/http2_test.go
@@ -14,6 +14,7 @@ import (
"strconv"
"strings"
"testing"
+ "time"
"golang.org/x/net/http2/hpack"
)
@@ -197,3 +198,30 @@ func TestSorterPoolAllocs(t *testing.T) {
t.Logf("Keys allocs = %v; want <1", allocs)
}
}
+
+// waitCondition reports whether fn eventually returned true,
+// checking immediately and then every checkEvery amount,
+// until waitFor has elapsed, at which point it returns false.
+func waitCondition(waitFor, checkEvery time.Duration, fn func() bool) bool {
+ deadline := time.Now().Add(waitFor)
+ for time.Now().Before(deadline) {
+ if fn() {
+ return true
+ }
+ time.Sleep(checkEvery)
+ }
+ return false
+}
+
+// waitErrCondition is like waitCondition but with errors instead of bools.
+func waitErrCondition(waitFor, checkEvery time.Duration, fn func() error) error {
+ deadline := time.Now().Add(waitFor)
+ var err error
+ for time.Now().Before(deadline) {
+ if err = fn(); err == nil {
+ return nil
+ }
+ time.Sleep(checkEvery)
+ }
+ return err
+}