Documentation
¶
Index ¶
- type Clock
- type MockClock
- func (c *MockClock) Add(d time.Duration)
- func (c *MockClock) NewTicker(d time.Duration) (<-chan time.Time, func())
- func (c *MockClock) NewTimer(d time.Duration) (<-chan time.Time, func() bool)
- func (c *MockClock) Now() time.Time
- func (c *MockClock) Set(t time.Time)
- func (c *MockClock) Since(t time.Time) time.Duration
- type RealClock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
Now() time.Time
NewTicker(d time.Duration) (<-chan time.Time, func())
NewTimer(d time.Duration) (<-chan time.Time, func() bool)
Since(t time.Time) time.Duration
}
Clock is a time abstraction which can be used to if you need to mock time in tests.
type MockClock ¶
type MockClock struct {
// contains filtered or unexported fields
}
MockClock is a mock implementation of the Clock interface.
func (*MockClock) Add ¶
Add advances the clock by the duration and triggers any timers or tickers that should fire.
func (*MockClock) NewTicker ¶
NewTicker creates a new ticker that will fire once you advance the clock by the duration.
func (*MockClock) NewTimer ¶
NewTimer creates a new timer that will fire once you advance the clock by the duration.
Click to show internal directories.
Click to hide internal directories.