Documentation
¶
Overview ¶
Package testlib provides utilities for testing.
Index ¶
- func EnvOrDefault(key, fallback string) string
- func IntegrationGuard(t *testing.T)
- func Logger(t *testing.T) zerolog.Logger
- func NewDatabase(t *testing.T, tlog zerolog.Logger, fns ...OptionsFunc) *db.QueriesExt
- func NewPersistent(t *testing.T, tlog zerolog.Logger, fns ...OptionsFunc) *db.QueriesExt
- func Ptr[T any](v T) *T
- type OptionsFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvOrDefault ¶
func IntegrationGuard ¶
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).
Types ¶
type OptionsFunc ¶
type OptionsFunc func(*options)
Click to show internal directories.
Click to hide internal directories.