Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func After ¶
After waits for the duration to elapse and then sends the current time on the returned channel. It is equivalent to NewTimer(d).C.
func Sleep ¶
Sleep pauses the current goroutine for at least the duration d. A negative or zero duration causes Sleep to return immediately.
func Tick ¶
Tick is a convenience wrapper for NewTicker providing access to the ticking channel only.
Types ¶
type Clock ¶
type Clock interface {
// Now returns the current local time.
Now() time.Time
// Sleep pauses the current goroutine for at least the duration d.
// A negative or zero duration causes Sleep to return immediately.
Sleep(d time.Duration)
// After waits for the duration to elapse and then sends the current time
// on the returned channel. It is equivalent to NewTimer(d).C.
After(d time.Duration) <-chan time.Time
// Tick is a convenience wrapper for NewTicker providing access to the
// ticking channel only.
Tick(d time.Duration) <-chan time.Time
// Ticker returns a new Ticker containing a channel that will send the
// time with a period specified by the duration argument. It adjusts
// the intervals or drops ticks to make up for slow receivers.
// The duration d must be greater than zero; if not, Ticker will panic.
Ticker(d time.Duration) *time.Ticker
}
Clock provides the functions from the time package.
var Work Clock
Work mirrors the behaviour of Go's time package.
type Mock ¶
type Mock interface {
Clock
// Set applies the passed-in time to the Clock's time.
Set(t time.Time) Mock
// Add changes the Clock's time by the passed-in duration.
Add(d time.Duration) Mock
// Freeze stops the clock's time.
Freeze() Mock
// IsFrozen is whether the clock's time is stopped.
IsFrozen() bool
// Unfreeze starts the clock's time again.
Unfreeze() Mock
Close()
}
Mock represents a manipulable Work. It is concurrent-friendly.
Click to show internal directories.
Click to hide internal directories.

