Documentation
¶
Overview ¶
Package faketime fakes time for tests
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoAdvance ¶
AutoAdvance returns a time source function that returns a time equal to 'start + ((n - 1) * dt)' where n is the number of serialized invocations of the returned function. The returned function will generate a time series of the form [start, start+dt, start+2dt, start+3dt, ...].
Types ¶
type ClockTimeWithOffset ¶ added in v0.8.0
type ClockTimeWithOffset struct {
// contains filtered or unexported fields
}
ClockTimeWithOffset allows controlling the passage of time. Intended to be used in tests.
func NewClockTimeWithOffset ¶ added in v0.8.0
func NewClockTimeWithOffset(offset time.Duration) *ClockTimeWithOffset
NewClockTimeWithOffset creates a ClockTimeWithOffset with the given start time.
func (*ClockTimeWithOffset) Advance ¶ added in v0.8.0
func (t *ClockTimeWithOffset) Advance(dt time.Duration) time.Time
Advance increases the time offset by dt, such that the next call to t.NowFunc()() returns current time + new offset.
func (*ClockTimeWithOffset) NowFunc ¶ added in v0.8.0
func (t *ClockTimeWithOffset) NowFunc() func() time.Time
NowFunc returns a time provider function for t.
type TimeAdvance ¶
type TimeAdvance struct {
// contains filtered or unexported fields
}
TimeAdvance allows controlling the passage of time. Intended to be used in tests.
func NewAutoAdvance ¶ added in v0.16.0
func NewAutoAdvance(start time.Time, autoDelta time.Duration) *TimeAdvance
NewAutoAdvance creates an auto-advancing clock with the given start time and autoDelta automatic time increase en each call to NowFunc().
func NewTimeAdvance ¶
func NewTimeAdvance(start time.Time) *TimeAdvance
NewTimeAdvance creates a TimeAdvance clock with the given start time. The returned clock does not automatically advance time when NowFunc is called.
func (*TimeAdvance) Advance ¶
func (t *TimeAdvance) Advance(dt time.Duration) time.Time
Advance advances t by dt, such that the next call to t.NowFunc()() returns current t + dt.
func (*TimeAdvance) NowFunc ¶
func (t *TimeAdvance) NowFunc() func() time.Time
NowFunc returns a time provider function for t.