MockClock is a fake source of time. It implements standard time operations, but allows the user to control the passage of time. Use the [Add] method to progress time.
| 32 | // |
| 33 | // Use the [Add] method to progress time. |
| 34 | type MockClock struct { |
| 35 | mu sync.RWMutex |
| 36 | now time.Time |
| 37 | |
| 38 | // The MockClock works by maintaining a list of waiters. |
| 39 | // Each waiter knows the time at which it should be resolved. |
| 40 | // When the clock advances, all waiters that are in range are resolved |
| 41 | // in chronological order. |
| 42 | waiters []waiter |
| 43 | } |
| 44 | |
| 45 | // NewMockClock builds a new mock clock |
| 46 | // using the current actual time as the initial time. |
nothing calls this directly
no outgoing calls
no test coverage detected