FakeClock implements clock.Clock, but returns an arbitrary time.
type FakeClock struct { FakePassiveClock // contains filtered or unexported fields }
func NewFakeClock(t time.Time) *FakeClock
NewFakeClock constructs a fake clock set to the provided time.
func (f *FakeClock) After(d time.Duration) <-chan time.Time
After is the fake version of time.After(d).
func (f *FakeClock) AfterFunc(d time.Duration, cb func()) clock.Timer
AfterFunc is the Fake version of time.AfterFunc(d, cb).
func (f *FakeClock) HasWaiters() bool
HasWaiters returns true if After or AfterFunc has been called on f but not yet satisfied (so you can write race-free tests).
func (f *FakeClock) NewTicker(d time.Duration) clock.Ticker
NewTicker returns a new Ticker.
func (f *FakeClock) NewTimer(d time.Duration) clock.Timer
NewTimer constructs a fake timer, akin to time.NewTimer(d).
func (f *FakeClock) SetTime(t time.Time)
SetTime sets the time.
func (f *FakeClock) Sleep(d time.Duration)
Sleep is akin to time.Sleep
func (f *FakeClock) Step(d time.Duration)
Step moves the clock by Duration and notifies anyone that's called After, Tick, or NewTimer.
func (f *FakeClock) Tick(d time.Duration) <-chan time.Time
Tick constructs a fake ticker, akin to time.Tick
FakePassiveClock implements PassiveClock, but returns an arbitrary time.
type FakePassiveClock struct {
// contains filtered or unexported fields
}
func NewFakePassiveClock(t time.Time) *FakePassiveClock
NewFakePassiveClock returns a new FakePassiveClock.
func (f *FakePassiveClock) Now() time.Time
Now returns f's time.
func (f *FakePassiveClock) SetTime(t time.Time)
SetTime sets the time on the FakePassiveClock.
func (f *FakePassiveClock) Since(ts time.Time) time.Duration
Since returns time since the time in f.
IntervalClock implements clock.PassiveClock, but each invocation of Now steps the clock forward the specified duration. IntervalClock technically implements the other methods of clock.Clock, but each implementation is just a panic.
Deprecated: See SimpleIntervalClock for an alternative that only has the methods of PassiveClock.
type IntervalClock struct { Time time.Time Duration time.Duration }
func (*IntervalClock) After(d time.Duration) <-chan time.Time
After is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) AfterFunc(d time.Duration, f func()) clock.Timer
AfterFunc is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTicker(d time.Duration) clock.Ticker
NewTicker has no implementation yet and is omitted. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTimer(d time.Duration) clock.Timer
NewTimer is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (i *IntervalClock) Now() time.Time
Now returns i's time.
func (i *IntervalClock) Since(ts time.Time) time.Duration
Since returns time since the time in i.
func (*IntervalClock) Sleep(d time.Duration)
Sleep is unimplemented, will panic.
func (*IntervalClock) Tick(d time.Duration) <-chan time.Time
Tick is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
SimpleIntervalClock implements clock.PassiveClock, but each invocation of Now steps the clock forward the specified duration
type SimpleIntervalClock struct { Time time.Time Duration time.Duration }
func (i *SimpleIntervalClock) Now() time.Time
Now returns i's time.
func (i *SimpleIntervalClock) Since(ts time.Time) time.Duration
Since returns time since the time in i.