Documentation ¶
Overview ¶
Package clockmock provides tools for mocking time functions
Index ¶
- type Mock
- func (m *Mock) Add(d time.Duration)
- func (m *Mock) After(d time.Duration) <-chan time.Time
- func (m *Mock) AfterFunc(d time.Duration, f func()) clock.Timer
- func (m *Mock) Now() time.Time
- func (m *Mock) Set(t time.Time)
- func (m *Mock) SetSpeed(speed float64)
- func (m *Mock) Since(t time.Time) time.Duration
- func (m *Mock) Sleep(d time.Duration)
- func (m *Mock) Ticker(d time.Duration) clock.Ticker
- func (m *Mock) Timer(d time.Duration) clock.Timer
- func (m *Mock) Until(t time.Time) time.Duration
- func (m *Mock) WithDeadline(parent context.Context, deadline time.Time) (context.Context, context.CancelFunc)
- func (m *Mock) WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock implementation of the Clock
func (*Mock) AfterFunc ¶
AfterFunc returns a timer that will call f when the mock current time becomes > m.Now().Add(d)
func (*Mock) SetSpeed ¶
SetSpeed starts mock time to run with the given speed until Mock.ctx becomes done or speed becomes changed. While time is running, current time for the mock will be the following:
mock time := mock start time + (real time duration from the start) * speed + mock duration added with Set, Add
func (*Mock) Ticker ¶
Ticker returns a ticker that will fire every time when the mock current time becomes > mock previous time + d
func (*Mock) Timer ¶
Timer returns a timer that will fire when the mock current time becomes > m.Now().Add(d)
Click to show internal directories.
Click to hide internal directories.