clocktest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package clocktest exists to allow interoperability with our Clock interface and the Clockwork FakeClock. Compatibility between Go interfaces is shallow, since function signatures containing other interfaces within an interface will be compared by their exact (nominal) type. Therefore, for the three Clock functions returning Timer or Ticker, we need to wrap those into functions returning the Clockwork version of the interface instead.

We also expose BlockUntilContext directly for convenience, as it is not exposed in Clockwork FakeClock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeClock

type FakeClock interface {
	internal.Clock
	Advance(d time.Duration)
	BlockUntil(waiters int)
	BlockUntilContext(ctx context.Context, n int) error
}

FakeClock provides an interface for a clock which can be manually advanced through time. For more information, see the documentation for Clockwork. https://pkg.go.dev/github.com/jonboulle/clockwork

func NewFakeClock

func NewFakeClock() FakeClock

NewFakeClock creates a new FakeClock using Clockwork.

func NewFakeClockAt

func NewFakeClockAt(t time.Time) FakeClock

NewFakeClockAt creates a new FakeClock using Clockwork set to a specific time, to provide fully deterministic clock behavior.

Jump to

Keyboard shortcuts

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