Documentation
¶
Overview ¶
Package timeutil provides shared time abstractions for deterministic testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock abstracts time operations so production code uses real time and tests can inject controllable fakes.
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock implements Clock for deterministic testing. Use Advance() to manually progress time and fire pending timers, or use NewInstantFakeClock() for tests that just need zero-delay After().
func NewFakeClock ¶
func NewFakeClock() *FakeClock
NewFakeClock creates a FakeClock anchored to a fixed time. After() calls register timers that fire when Advance() is called.
func NewInstantFakeClock ¶
func NewInstantFakeClock() *FakeClock
NewInstantFakeClock creates a FakeClock where After() returns immediately. Useful for tests that just need to eliminate delays without controlling timing.
func (*FakeClock) After ¶
After returns a channel that fires when Advance() progresses past the duration. In instant mode (NewInstantFakeClock), the channel fires immediately.
func (*FakeClock) PendingTimers ¶
PendingTimers returns the number of timers waiting to fire.