Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Freeze ¶
Freeze makes Now return ts until t and its subtests finish, then puts back the backend it replaced. Calls nest: an inner Freeze gives back the outer one when its test ends. The backend is process-global, so a test that calls Freeze must not run in parallel with one that reads the clock.
func Now ¶
Now returns the current time from the package's backend. Use it rather than time.Now everywhere but a deadline or an elapsed-time measurement, so a test can control what "now" means.
func Set ¶
func Set(t interface{ Cleanup(func()) }, c Clock)
Set serves Now from c until t and its subtests finish, then puts back the backend it replaced. Use it when a test needs Now to change; Freeze covers a single instant. Like Freeze, it swaps a process-global backend and is not safe under t.Parallel.