testbarrier

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: 0BSD Imports: 3 Imported by: 0

Documentation

Overview

Package testbarrier implements a barrier for testing asynchronous systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitForGroup

func WaitForGroup(t testingT, wg *sync.WaitGroup, d time.Duration)

WaitForGroup waits for a sync.WaitGroup for up to the specified duration. If the deadline expires, the test will fail immediately.

Types

type Barrier

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

Barrier blocks tests for a limited duration until an event happens.

func New

func New() *Barrier

New creates a Barrier.

func (*Barrier) Lift

func (b *Barrier) Lift()

Lift the barrier. Must be called when the event happens.

This method is idempotent and can be called multiple times.

func (*Barrier) Wait

func (b *Barrier) Wait()

Wait for the barrier to lift indefinitely.

Eventually, the go test timeout will kick in. It can introduce higher delays than WaitFor on failures, but on the other hand it is much friendlier to debugging.

func (*Barrier) WaitFor added in v0.8.0

func (b *Barrier) WaitFor(t testingT, d time.Duration)

WaitFor for the barrier to lift for up to a duration `d`. If the deadline expires, the test will fail immediately.

Jump to

Keyboard shortcuts

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