Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface { AfterFunc(d time.Duration, f func()) Now() time.Time Sleep(d time.Duration) }
Clock represents an interface to the functions in the standard library time package. Two implementations are available in the clock package. The first is a real-time clock which simply wraps the time package's functions. The second is a mock clock which will only make forward progress when programmatically adjusted.
type Mock ¶
Mock represents a mock clock that only moves forward programmically. It can be preferable to a real-time clock when testing time-based functionality.
func NewMock ¶
func NewMock() *Mock
NewMock returns an instance of a mock clock. The current time of the mock clock on initialization is the Unix epoch.
func (*Mock) Add ¶
Add moves the current time of the mock clock forward by the duration. This should only be called from a single goroutine at a time.
func (*Mock) AfterFunc ¶
AfterFunc waits for the duration to elapse and then executes a function. A Timer is returned that can be stopped.