testboil

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

testboil contains functions consistently reused for testing. It doesn't have any dependencies except standard library and go_away_boilerplate

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureStdout added in v1.3.8

func CaptureStdout(t *testing.T, do func(t *testing.T)) string

CaptureStdout when do is called. Restore stdout as test cleanup

func CheckEqualsWithinTimeout

func CheckEqualsWithinTimeout[T comparable](currMu *sync.Mutex, curr *T, want T, timeout, pollRate time.Duration) bool

CheckEqualsWithinTimeout by polling at pollRate. Will at most block for timeout, when it will return false in case that curr != want

func CreateTestFile

func CreateTestFile(t *testing.T, fileName string) *os.File

CreateTestFile or fatal trying. Since it t.Fatalf on failure, return value won't matter. So the return value can be assumed to never be nil

func FailTestIfDiff added in v1.3.9

func FailTestIfDiff[C comparable](t *testing.T, got, want C)

func ReturnsOnContextCancel

func ReturnsOnContextCancel(t *testing.T, f func(context.Context), testTimeout time.Duration)

ReturnsOnContextCancel by creating a context and ensuring that the function returns once the context has been cancelled

Types

This section is empty.

Jump to

Keyboard shortcuts

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