TrackTimers replaces internal.TimerAfterFunc with one that tracks timer creations, stoppages and expirations. CheckTimers should then be invoked at the end of the test to validate that all timers created have either executed or are cancelled.
()
| 331 | // the end of the test to validate that all timers created have either executed |
| 332 | // or are cancelled. |
| 333 | func TrackTimers() { |
| 334 | globalTimerTracker = &timerFactory{ |
| 335 | allocatedTimers: make(map[internal.Timer][]uintptr), |
| 336 | } |
| 337 | internal.TimeAfterFunc = globalTimerTracker.timeAfterFunc |
| 338 | } |
| 339 | |
| 340 | // CheckTimers undoes the effects of TrackTimers, and fails unit tests if not |
| 341 | // all timers were cancelled or executed. It is invalid to invoke this function |
no outgoing calls