(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestCacheReset(t *testing.T) { |
| 58 | var i int64 |
| 59 | g := func() (int64, error) { |
| 60 | i++ |
| 61 | return i, nil |
| 62 | } |
| 63 | |
| 64 | c := ResettableCached(g, 10*time.Minute) |
| 65 | clock := clock.NewMock() |
| 66 | c.clock = clock |
| 67 | |
| 68 | test := func(exp int64) { |
| 69 | v, _ := c.Get() |
| 70 | if exp != v { |
| 71 | t.Errorf("expected %d, got %d", exp, v) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | test(1) |
| 76 | test(1) |
| 77 | c.Reset() |
| 78 | test(2) |
| 79 | test(2) |
| 80 | clock.Add(10*time.Minute + 1) |
| 81 | test(3) |
| 82 | } |
| 83 | |
| 84 | func TestRetryWithBackoff(t *testing.T) { |
| 85 | tests := []struct { |