fake backoff implementation for speeding up flakey test, fake Clock Test for sleep

This commit is contained in:
jay vyas
2016-02-24 11:56:22 -05:00
committed by Jay Vyas
parent b9cc128233
commit 4097cfe022
7 changed files with 61 additions and 21 deletions

View File

@@ -37,6 +37,16 @@ func TestFakeClock(t *testing.T) {
}
}
func TestFakeClockSleep(t *testing.T) {
startTime := time.Now()
tc := NewFakeClock(startTime)
tc.Sleep(time.Duration(1) * time.Hour)
now := tc.Now()
if now.Sub(startTime) != time.Hour {
t.Errorf("Fake sleep failed, expected time to advance by one hour, instead, its %v", now.Sub(startTime))
}
}
func TestFakeAfter(t *testing.T) {
tc := NewFakeClock(time.Now())
if tc.HasWaiters() {