testlib

package
v0.0.0-...-bdc5b51 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package testlib provides utilities for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvOrDefault

func EnvOrDefault(key, fallback string) string

func IntegrationGuard

func IntegrationGuard(t *testing.T)

func Logger

func Logger(t *testing.T) zerolog.Logger

Logger returns a new logger that is configured to write to the test's log.

func NewDatabase

func NewDatabase(t *testing.T, tlog zerolog.Logger, fns ...OptionsFunc) *db.QueriesExt

NewDatabase creates a new database based on the shared postgres instance and calls the close function when the test is done using t.Cleanup. To use a shared instance of the database, use NewPersistent.

func NewPersistent

func NewPersistent(t *testing.T, tlog zerolog.Logger, fns ...OptionsFunc) *db.QueriesExt

NewPersistent creates a new database that is persistent across tests. The database is created with a random name and returns a function to close the connection.

NOTE: Databases are not cleaned up or removed. It is assumed that you are using a postgres instance that will be reset or cleaned up after the tests are run (docker, k8s, etc).

func Ptr

func Ptr[T any](v T) *T

Ptr returns a point to the provided values. Useful for initializing strings and other primtive types directly as pointers.

Types

type OptionsFunc

type OptionsFunc func(*options)

Jump to

Keyboard shortcuts

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