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
Now() time.Time
// After waits for the duration to elapse and then sends the current time on the returned channel
After(d time.Duration) <-chan time.Time
// Sleep pauses the current goroutine for at least the duration d
Sleep(d time.Duration)
// NewTimer creates a new Timer that will send the current time on its channel after at least duration d
NewTimer(d time.Duration) Timer
// AfterFunc waits for the duration to elapse and then calls f in its own goroutine
AfterFunc(d time.Duration, f func()) Timer
// NewTicker returns a new Ticker containing a channel that will send the current time on the channel after each tick
NewTicker(d time.Duration) Ticker
}
Clock represents an interface to time-related functionality. It wraps benbjohnson/clock.Clock to provide mockable time operations.
type MockClock ¶
type MockClock interface {
Clock
// Add moves the mock clock forward by the specified duration
Add(d time.Duration)
// Set sets the mock clock to a specific time
Set(t time.Time)
}
MockClock extends Clock with methods to control time in tests
Click to show internal directories.
Click to hide internal directories.