Make TestTime_Elapsed less flaky

This test fails sometimes because the elapsed time is 1.999s which
is less than 2s, but very close to 2s to not matter.
pull/6430/head
Jason Wilder 2016-04-20 14:13:32 -06:00
parent f679787080
commit 7aefe1e889
1 changed files with 2 additions and 1 deletions

View File

@ -54,7 +54,8 @@ func TestTimer_Elapsed(t *testing.T) {
time.Sleep(2 * time.Second)
tmr.StopTimer()
e := tmr.Elapsed()
if time.Duration(2*time.Second) > e || e > time.Duration(3*time.Second) {
if time.Duration(1990*time.Millisecond) > e || e > time.Duration(3*time.Second) {
t.Errorf("expected around %s got %s", time.Duration(2*time.Second), e)
}
}