testing

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeClock

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

FakeClock implements clock.Clock, but returns an arbitrary time.

func NewFakeClock

func NewFakeClock(t time.Time) *FakeClock

NewFakeClock constructs a fake clock set to the provided time.

func (*FakeClock) After

func (f *FakeClock) After(d time.Duration) <-chan time.Time

After is the fake version of time.After(d).

func (*FakeClock) HasWaiters

func (f *FakeClock) HasWaiters() bool

HasWaiters returns true if After has been called on f but not yet satisfied (so you can write race-free tests).

func (*FakeClock) NewTimer

func (f *FakeClock) NewTimer(d time.Duration) clock.Timer

NewTimer constructs a fake timer, akin to time.NewTimer(d).

func (*FakeClock) Now

func (f *FakeClock) Now() time.Time

Now returns f's time.

func (*FakeClock) SetTime

func (f *FakeClock) SetTime(t time.Time)

SetTime sets the time.

func (*FakeClock) Since

func (f *FakeClock) Since(ts time.Time) time.Duration

Since returns time since the time in f.

func (*FakeClock) Sleep

func (f *FakeClock) Sleep(d time.Duration)

Sleep is akin to time.Sleep

func (*FakeClock) Step

func (f *FakeClock) Step(d time.Duration)

Step moves the clock by Duration and notifies anyone that's called After, Tick, or NewTimer.

func (*FakeClock) Tick

func (f *FakeClock) Tick(d time.Duration) <-chan time.Time

Tick constructs a fake ticker, akin to time.Tick

type IntervalClock

type IntervalClock struct {
	Time     time.Time
	Duration time.Duration
}

IntervalClock implements clock.Clock, but each invocation of Now steps the clock forward the specified duration

func (*IntervalClock) After

func (*IntervalClock) After(_ time.Duration) <-chan time.Time

After is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.

func (*IntervalClock) NewTimer

func (*IntervalClock) NewTimer(_ time.Duration) clock.Timer

NewTimer is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.

func (*IntervalClock) Now

func (i *IntervalClock) Now() time.Time

Now returns i's time.

func (*IntervalClock) Since

func (i *IntervalClock) Since(ts time.Time) time.Duration

Since returns time since the time in i.

func (*IntervalClock) Sleep

func (*IntervalClock) Sleep(_ time.Duration)

Sleep is unimplemented, will panic.

func (*IntervalClock) Tick

func (*IntervalClock) Tick(_ time.Duration) <-chan time.Time

Tick is unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.

Jump to

Keyboard shortcuts

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