testutil

package
v0.0.0-...-94dd193 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides utilities for use in tests.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAfter

func ErrorAfter(timeout time.Duration, wg *sync.WaitGroup) error

ErrorAfter will return an error after the provided timeout has passed if the provided WaitGroup has not unblocked. All Add() calls to the WaitGroup must be performed before calling this function.

func ErrorAfterFunc

func ErrorAfterFunc(timeout time.Duration, f func()) error

ErrorAfterFunc will return an error after the provided timeout has passed if the provided function has not returned.

func FatalAfter

func FatalAfter(t testing.TB, timeout time.Duration, wg *sync.WaitGroup)

FatalAfter will fatal the test after the provided timeout has passed if the provided WaitGroup has not unblocked. All Add() calls to the WaitGroup must be performed before calling this function.

func FatalAfterFunc

func FatalAfterFunc(t testing.TB, timeout time.Duration, f func())

FatalAfterFunc will fatal the test after the provided timeout has passed if the provided function has not returned.

Example (Fatal)
var t testing.T
// This test will fatal
FatalAfterFunc(&t, 10*time.Millisecond, func() {
	time.Sleep(1 * time.Millisecond)
})
Output:

Example (Success)
var t testing.T
// This test will pass
FatalAfterFunc(&t, 10*time.Millisecond, func() {
	time.Sleep(1 * time.Millisecond)
})
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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