testutil

package
v0.26.0 Latest Latest
Warning

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

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

Documentation

Overview

Package testutil provides common test helper utilities for the Dingo project. It replaces ad-hoc time.Sleep patterns with deterministic synchronization helpers that make tests faster and more reliable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequireNoReceive

func RequireNoReceive[T any](
	t *testing.T,
	ch <-chan T,
	duration time.Duration,
	msg string,
)

RequireNoReceive verifies that no value is received on the given channel within the specified duration. This replaces the pattern of time.Sleep followed by a non-blocking channel read to confirm that nothing was sent.

func RequireReceive

func RequireReceive[T any](
	t *testing.T,
	ch <-chan T,
	timeout time.Duration,
	msg string,
) T

RequireReceive waits for a value on the given channel or fails the test if the timeout expires. This replaces the common pattern of time.Sleep followed by reading a channel.

func WaitForCondition

func WaitForCondition(
	t *testing.T,
	condition func() bool,
	timeout time.Duration,
	msg string,
)

WaitForCondition polls the given condition function until it returns true or the timeout expires. This replaces the common pattern of time.Sleep followed by an assertion check.

func WaitForConditionWithInterval

func WaitForConditionWithInterval(
	t *testing.T,
	condition func() bool,
	timeout time.Duration,
	interval time.Duration,
	msg string,
)

WaitForConditionWithInterval is like WaitForCondition but allows specifying a custom polling interval.

Types

This section is empty.

Jump to

Keyboard shortcuts

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