Set the mock clock to a specific time. NOTE: scheduled wakeup calls are not modified when resetting the clock to an earlier time; for example, suppose the current time is X, and there is a pending wakeup call at time X+1. If we reset the clock to X-2, the wakeup time will still be at X+1.
(t time.Time)
| 51 | // the current time is X, and there is a pending wakeup call at time X+1. If |
| 52 | // we reset the clock to X-2, the wakeup time will still be at X+1. |
| 53 | func (c *MockClock) Set(t time.Time) { |
| 54 | c.mutex.Lock() |
| 55 | defer c.mutex.Unlock() |
| 56 | |
| 57 | if t.After(c.now) { |
| 58 | c.advanceTo(t) |
| 59 | } else { |
| 60 | c.now = t // move back in time |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // Advances the mock clock by the specified duration. |
| 65 | func (c *MockClock) Advance(delta time.Duration) { |
no test coverage detected