tests

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

View Source
const DefaultWaitTimeout = 30 * time.Second

DefaultWaitTimeout is the default wait timeout. If you have a *testing.T, use WaitTimeout instead.

View Source
const TestInterval = 100 * time.Millisecond

TestInterval is just a sensible poll interval that gives fast tests without risk of spamming

Variables

This section is empty.

Functions

func AssertEventually

func AssertEventually(t *testing.T, f func() bool)

AssertEventually waits for f to return true

func AssertLogCountEventually

func AssertLogCountEventually(t *testing.T, observedLogs *observer.ObservedLogs, msg string, count int)

AssertLogCountEventually waits until at least count log message containing the specified msg is emitted

func AssertLogEventually

func AssertLogEventually(t *testing.T, observedLogs *observer.ObservedLogs, msg string)

AssertLogEventually waits until at least one log message containing the specified msg is emitted. NOTE: This does not "pop" messages so it cannot be used multiple times to check for new instances of the same msg. See AssertLogCountEventually instead.

Get a *observer.ObservedLogs like so:

observedZapCore, observedLogs := observer.New(zap.DebugLevel)
lggr := logger.TestLogger(t, observedZapCore)

func Context

func Context(tb TestingT) (ctx context.Context)

func RequireLogMessage

func RequireLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)

RequireLogMessage fails the test if emitted logs don't contain the given message

func RequireSignal

func RequireSignal(t *testing.T, ch <-chan struct{}, failMsg string)

RequireSignal waits for the channel to close (or receive anything) and fatals the test if the default wait timeout is exceeded

func WaitTimeout

func WaitTimeout(t *testing.T) time.Duration

WaitTimeout returns a timeout based on the test's Deadline, if available. Especially important to use in parallel tests, as their individual execution can get paused for arbitrary amounts of time.

Types

type TestingT

type TestingT interface {
	require.TestingT
	Helper()
	Cleanup(func())
}

Jump to

Keyboard shortcuts

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