testclock

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is a deterministic clock for tests.

func New

func New(start time.Time) *Clock

New returns a clock starting at t (or Unix 0 if zero).

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance moves time forward and fires due timers/tickers.

func (*Clock) After

func (c *Clock) After(d time.Duration) <-chan time.Time

After returns a channel that receives at now+d.

func (*Clock) NewTicker

func (c *Clock) NewTicker(d time.Duration) shiftlock.Ticker

NewTicker creates a fake ticker.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the current fake time.

func (*Clock) Set

func (c *Clock) Set(t time.Time)

Set sets absolute time and fires due timers.

func (*Clock) Since

func (c *Clock) Since(t time.Time) time.Duration

Since returns Now().Sub(t).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL