Documentation
¶
Overview ¶
Package clocktest pins clock.Now for the tests of a package.
A test package whose code under test reads the clock calls Freeze once, from its TestMain, before m.Run, and builds its fixtures relative to Instant. Tests never reassign clock.Now and never restore it: a test that needs another instant passes it explicitly (evaluation date, currentDateTime, ...).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Freeze ¶
func Freeze()
Freeze pins clock.Now to Instant. Call it from TestMain only, before m.Run.
func FreezeStepping ¶
FreezeStepping pins clock.Now to a deterministic stepping clock: the first call returns Instant, and every following call returns a time that is step later than the previous one (strictly increasing and safe for concurrent use, with no relation to the real time). It is for the packages whose tests assert that a date advances (a cache refresh after a poll or a forced refresh). Call it from TestMain only, before m.Run, and never reassign the clock afterwards.
Types ¶
This section is empty.