Documentation ¶
Index ¶
- func Add(d time.Duration) error
- func Reset() *clockapi.Mock
- func Set(t time.Time)
- type Clock
- func (c *Clock) Add(d time.Duration) error
- func (c *Clock) After(d time.Duration) <-chan time.Time
- func (c *Clock) AfterFunc(d time.Duration, f func()) *clockapi.Timer
- func (c *Clock) Now() time.Time
- func (c *Clock) Reset() *clockapi.Mock
- func (c *Clock) Set(t time.Time)
- func (c *Clock) Since(t time.Time) time.Duration
- func (c *Clock) Sleep(d time.Duration)
- func (c *Clock) Tick(d time.Duration) <-chan time.Time
- func (c *Clock) Ticker(d time.Duration) *clockapi.Ticker
- func (c *Clock) Timer(d time.Duration) *clockapi.Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add moves the mocked global clock forward the given duration. It will error if the global clock is not mocked.
Types ¶
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock is a non-package level wrapper around time that supports stubbing. It will use its localized stubs (allowing for parallelized unit tests where package level stubbing would cause issues). It falls back to any package level time stubs for non-parallel, cross-package integration testing scenarios.
If nothing is stubbed, it defaults to default time behavior in the time package.
func (*Clock) Add ¶
Add moves clock forward time.Duration if it is mocked. It will error if the clock is not mocked.
func (*Clock) Reset ¶
Reset removes local clock.Mock. Returns any existing Mock if set in case lingering time operations are attached to it.