Documentation
¶
Overview ¶
Package keeltime provides a replaceable clock for deterministic tests.
Code reads the current time through Now. Tests can switch it to a fixed time with Static or to a strictly increasing time with Incremental. The package variables are not synchronized; switch providers before concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Now returns the current time. It defaults to [time.Now] and is replaced // by [Static] and [Incremental]. Now = time.Now // NowStaticNSec is the Unix time in nanoseconds returned by the static // provider (2021-01-01 11:00:00 UTC). NowStaticNSec = int64(1609498800e9) // NowIncrementalNSec is the Unix time in nanoseconds the incremental // provider returns next. NowIncrementalNSec = NowStaticNSec )
Functions ¶
func Incremental ¶
func Incremental()
Incremental sets Now to return NowIncrementalNSec and advance it by one nanosecond on each call. It is not safe for concurrent use.
func ResetIncremental ¶
func ResetIncremental()
ResetIncremental resets NowIncrementalNSec to NowStaticNSec.
Types ¶
This section is empty.