Documentation
¶
Overview ¶
Package clock provides a time abstraction for testable code.
The Clock interface has a single method Now() and is implemented by OsClock for production (delegates to time.Now) and TestClock for tests (allows deterministic time advancement via Advance).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock is a small interface abstracting time operations the package needs. Use this to inject testable/fake clocks in unit tests rather than relying on time.Now directly.
type TestClock ¶
type TestClock struct {
// contains filtered or unexported fields
}
TestClock is a simple, mutex-protected, manually-advancable clock useful for tests. It allows deterministic control of Now() by setting an initial time and advancing it as needed.
func NewTestClock ¶
NewTestClock constructs a TestClock seeded to the provided time.