clocktest

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package clocktest bridges clock capabilities to testing/synctest and manual advancement. Start with SystemBubble when the whole test can use a synctest bubble, or Advance when explicit manual-clock progress is required.

Helpers do not install a global clock or manage a manual clock's lifetime. Callers own manual clock release and callback cooperation. The package uses Go's testing facilities without external infrastructure or cgo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Advance

func Advance(t testing.TB, clock *manual.Clock, duration time.Duration) manual.Result

Advance advances a manual clock, waits for all synchronously triggered work, and fails the current test if either phase reports an error. The clock must be non-nil. The wait uses t.Context(), but cancellation cannot interrupt an Advance that is itself blocked by an uncooperative callback.

func SystemBubble

func SystemBubble(t *testing.T, test func(*testing.T, clock.System))

SystemBubble runs test in a testing/synctest bubble with a System clock. Prefer this helper when the complete unit under test can live inside one bubble. Use dependency-injected manual clocks for explicit business timestamps, wall jumps, and cross-package clock contracts.

func Wait

func Wait(ctx context.Context) error

Wait checks ctx and then waits for every other goroutine in the current synctest bubble to become durably blocked. It must be called from a bubble unless ctx is already canceled. A nil context panics. Cancellation is checked before and after the wait; it does not interrupt synctest.Wait.

Types

This section is empty.

Jump to

Keyboard shortcuts

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