Documentation ¶
Overview ¶
Package ttime implements a testable alternative to the Go "time" package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetTime ¶
func SetTime(t Time)
SetTime configures what 'Time' implementation to use for each of the package-level methods.
Types ¶
type DefaultTime ¶
type DefaultTime struct{}
DefaultTime is a Time that behaves normally
func (*DefaultTime) After ¶ added in v1.1.0
func (*DefaultTime) After(d time.Duration) <-chan time.Time
After sleeps for the given duration and then writes to to the returned channel
func (*DefaultTime) Sleep ¶
func (*DefaultTime) Sleep(d time.Duration)
Sleep sleeps for the given duration
type TestTime ¶
type TestTime struct { // IsLudicrousSpeed indicates whether sleeps will all succeed instantly IsLudicrousSpeed bool // contains filtered or unexported fields }
TestTime implements a time that is able to be moved forward easily
func NewTestTime ¶
func NewTestTime() *TestTime
NewTestTime returns a default TestTime. It will not be LudicrousSpeed and will behave like a normal time
func (*TestTime) After ¶ added in v1.1.0
After returns a channel which is written to after the given duration, taking into account time-warping
func (*TestTime) LudicrousSpeed ¶
LudicrousSpeed can be called to toggle LudicrousSpeed (default off). When LudicrousSpeed is engaged, all calls to "sleep" will succeed instantly.