Documentation
¶
Overview ¶
LICENSE: clock
Index ¶
- type Clock
- func (st *Clock) Advance(d time.Duration) int
- func (st *Clock) AdvanceTo(t time.Time) int
- func (st *Clock) Block(t *testing.T, pendingTimerCount int)
- func (st *Clock) BlockThenAdvance(t *testing.T, pendingTimerCount int, d time.Duration) int
- func (st *Clock) BlockThenStep(t *testing.T, pendingTimerCount int) (time.Duration, bool)
- func (st *Clock) Clock() clock.Clock
- func (st *Clock) Next() time.Duration
- func (st *Clock) Now() time.Time
- func (st *Clock) Since(t time.Time) time.Duration
- func (st *Clock) Step() (time.Duration, bool)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock provides facilities to manipulate time, timers, and tickers. It is designed for use in deterministic testing of time reliant code. Since deterministism is hard to achieve when influencing a clock from multiple goroutines, the FakeClock disallows concurrent access by-design.
func (*Clock) Advance ¶
Advance moves the clock forward and returns the number of pending timers that were triggered.
func (*Clock) AdvanceTo ¶
AdvanceTo moves the clock forward to the specific time and returns the number of pending timers that were triggered.
func (*Clock) Block ¶
Block waits until there are at least the given count of tickers/timers pending.
func (*Clock) BlockThenAdvance ¶
func (*Clock) BlockThenStep ¶
func (*Clock) Next ¶
Next returns how much time needs to elapse to fire the next pending timer. It returns a negative duration if there are no pending timers.
func (*Clock) Now ¶
Now provides functionality equivalent to time.Now according to the the test clock.
func (*Clock) Since ¶
Since provides functionality equivalent to time.Since according to the the test clock.