Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface { // NewTicker returns a new Ticker containing a channel that will send // the current time on the channel after each tick. The typical period of the // ticks is specified by the duration argument, but in the case of a fake // ticker ticks may be manually sent. Include a tag so that tests can // intercept tickers and handle appropriately. NewTicker(d time.Duration, tag any) Ticker }
Clock is a simplified clock interface which facilitates testing of delays and timeouts by allowing all waits to be tagged so that test code can react to specific waits and respond accordingly.
func NewRealClock ¶
func NewRealClock() Clock
NewRealClock returns a clock which just calls out to real time functions.
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock is a type which exposes "faked" time functions which can be useful for determinstically (and quickly) testing time-dependent code.
func NewFakeClock ¶
func NewFakeClock(tickerListener chan *FakeTicker) *FakeClock
NewFakeClock return a new fake clock, and must be passed a tickerListener Channel where all new tickers will be sent.
type FakeTicker ¶
type FakeTicker struct { // Tag can be used to identify tickers for tests. Tag any // contains filtered or unexported fields }
FakeTicker is a Ticker implementation which will only send ticks when Tick is manually called.
func (*FakeTicker) Stop ¶
func (t *FakeTicker) Stop()
Stop prevents future Tick calls from succeeding, concurrent Tick calls may or may not be successful.