Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface { // Now returns the current time, as defined by this Clock. Now() time.Time // NewTimer creates a new Timer associated with this Clock. NewTimer(d time.Duration) Timer // NewTimerAt creates a new Timer that fires at or after the given time. NewTimerAt(at time.Time) Timer }
Clock is a simple interface that returns a "current" timestamp. This will generally be the current time, but the Clock interface can be mocked during testing to make testing time-sensitive components deterministic.
type Timer ¶
type Timer interface { // GetC returns this Timer's signal channel. For real clocks, this simply returns a time.Timer.C. GetC() <-chan time.Time // Stop stops the timer. Like time.Timer.Stop(), it returns true if the call stops the timer, // false if the timer has already expired or been stopped. See documentation for time.Timer.Stop() // for more information about this method's behavior. Stop() bool }
Timer mimics a time.Timer, providing a channel that delivers a signal after a certain amount of time has elapsed. When associated with a MockClock, Timer delivers its signal when the MockClock's time is programmatically set to a certain point.
func NewStoppedTimer ¶
func NewStoppedTimer() Timer
NewStoppedTimer creates a Timer that will never fire.
Click to show internal directories.
Click to hide internal directories.