Documentation
¶
Overview ¶
Package clock provides a small Clock abstraction so time-dependent logic (notably the per-day spend-cap reset) can be driven by a fake clock in tests. Production code uses RealClock (UTC); tests inject FakeClock and advance it across day boundaries deterministically.
The rest of the codebase calls time.Now() directly; this package is intentionally narrow and only adopted where day-boundary behaviour must be tested without sleeping or racing the wall clock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Clock ¶
type Clock interface {
// Now returns the current time. Implementations SHOULD return UTC
// so callers can derive a stable YYYY-MM-DD day key.
Now() time.Time
}
Clock is the minimal time source consumed by the spend-cap engine.
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock is a deterministic Clock for tests. The zero value is not usable — construct with NewFakeClock.
func NewFakeClock ¶
NewFakeClock returns a FakeClock pinned to t (normalised to UTC).