(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestBackoffReset(t *testing.T) { |
| 53 | id := "_idReset" |
| 54 | tc := clock.NewFakeClock(time.Now()) |
| 55 | step := time.Second |
| 56 | maxDuration := step * 5 |
| 57 | b := NewFakeBackOff(step, maxDuration, tc) |
| 58 | startTime := tc.Now() |
| 59 | |
| 60 | // get to backoff = maxDuration |
| 61 | for i := 0; i <= int(maxDuration/step); i++ { |
| 62 | tc.Step(step) |
| 63 | b.Next(id, tc.Now()) |
| 64 | } |
| 65 | |
| 66 | // backoff should be capped at maxDuration |
| 67 | if !b.IsInBackOffSince(id, tc.Now()) { |
| 68 | t.Errorf("expected to be in Backoff got %s", b.Get(id)) |
| 69 | } |
| 70 | |
| 71 | lastUpdate := tc.Now() |
| 72 | tc.Step(2*maxDuration + step) // time += 11s, 11 > 2*maxDuration |
| 73 | if b.IsInBackOffSince(id, lastUpdate) { |
| 74 | t.Errorf("expected to not be in Backoff after reset (start=%s, now=%s, lastUpdate=%s), got %s", startTime, tc.Now(), lastUpdate, b.Get(id)) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func TestBackoffHighWaterMark(t *testing.T) { |
| 79 | id := "_idHiWaterMark" |
nothing calls this directly
no test coverage detected