Documentation ¶
Index ¶
- Variables
- func BaseServiceArchetype(tb testing.TB) *baseservice.Archetype
- func Logger(tb testing.TB) *slog.Logger
- func LoggerWarn(tb testing.TB) *slog.Logger
- func WaitOrTimeout[T any](tb testing.TB, waitChan <-chan T) T
- func WaitOrTimeoutN[T any](tb testing.TB, waitChan <-chan T, numValues int) []T
- func WaitTimeout() time.Duration
- func WrapTestMain(m *testing.M)
- type TimeStub
Constants ¶
This section is empty.
Variables ¶
var IgnoredKnownGoroutineLeaks = []goleak.Option{ goleak.IgnoreTopFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), }
Functions ¶
func BaseServiceArchetype ¶
func BaseServiceArchetype(tb testing.TB) *baseservice.Archetype
BaseServiceArchetype returns a new base service suitable for use in tests. Returns a new instance so that it's not possible to accidentally taint a shared object.
func Logger ¶
Logger returns a logger suitable for use in tests.
Defaults to informational verbosity. If env is set with `RIVER_DEBUG=true`, debug level verbosity is activated.
func LoggerWarn ¶
Logger returns a logger suitable for use in tests which outputs only at warn or above. Useful in tests where particularly noisy log output is expected.
func WaitOrTimeout ¶
WaitOrTimeout tries to wait on the given channel for a value to come through, and returns it if one does, but times out after a reasonable amount of time. Useful to guarantee that test cases don't hang forever, even in the event of something wrong.
func WaitOrTimeoutN ¶
WaitOrTimeoutN tries to wait on the given channel for N values to come through, and returns it if they do, but times out after a reasonable amount of time. Useful to guarantee that test cases don't hang forever, even in the event of something wrong.
func WaitTimeout ¶
WaitTimeout returns a duration broadly appropriate for waiting on an expected event in a test, and which is used for `TestSignal.WaitOrTimeout` in the main package and `WaitOrTimeout` above. Its main purpose is to allow a little extra leeway in GitHub Actions where we occasionally seem to observe subpar performance which leads to timeouts and test intermittency, while still keeping a tight a timeout for local test runs where this is never a problem.
func WrapTestMain ¶
WrapTestMain performs some common setup and teardown that should be shared amongst all packages. e.g. Configures a manager for test databases on setup, and checks for no goroutine leaks on teardown.
Types ¶
type TimeStub ¶
type TimeStub struct {
// contains filtered or unexported fields
}
TimeStub implements baseservice.TimeGenerator to allow time to be stubbed in tests.