1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #26662 from WeiZhang555/fix-flaky-unit-test

Fix flaky unit test
This commit is contained in:
John Howard 2016-09-17 18:32:11 -07:00 committed by GitHub
commit 56952e2159

View file

@ -47,14 +47,14 @@ func testHTTPTimeout(t *testing.T, timeout, epsilon time.Duration) {
t.Fatalf("The request should be canceled %v", err)
}
elapsed := time.Now().Sub(begin)
if elapsed < timeout || elapsed > timeout+epsilon {
if elapsed < timeout-epsilon || elapsed > timeout+epsilon {
t.Fatalf("elapsed time: got %v, expected %v (epsilon=%v)",
elapsed, timeout, epsilon)
}
}
func TestHTTPTimeout(t *testing.T) {
testHTTPTimeout(t, 5*time.Second, 1*time.Second)
testHTTPTimeout(t, 5*time.Second, 500*time.Millisecond)
}
func TestFailedConnection(t *testing.T) {