testutil

package
v0.0.0-...-0ff8765 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntegrationTest

func IntegrationTest(ctx context.Context, t *testing.T, integrationDeps ...IntegrationDependency) (context.Context, func())

IntegrationTest skips a test if the INTEGRATION_TEST env variable is not set while running go tests

func Must

func Must[T any](object T, err error) T

/ Must takes an object `T` and an `error`, usually the result of calling another method. / It and returns `T` if the error is `nil`, otherwise it panics with `err`. / This is useful to quickly unwrap fallible operations in tests without cluttering the code with lots of `if err != nil`

func PgDBFromContext

func PgDBFromContext(ctx context.Context, t *testing.T) *sqlx.DB

func PgUrlFromContext

func PgUrlFromContext(ctx context.Context, t *testing.T) string

/ PgUrlFromContext returns the database URL for the teemporary SQLite database

func SqliteDBFromContext

func SqliteDBFromContext(ctx context.Context, t *testing.T) *sqlx.DB

func SqliteUrlFromContext

func SqliteUrlFromContext(ctx context.Context, t *testing.T) string

/ SqliteUrlFromContext returns the database URL for the teemporary SQLite database

func TempDirFromContext

func TempDirFromContext(ctx context.Context, t *testing.T) string

/ TempDirFromContext returns the path to the generated tempdir

Types

type IntegrationDependency

type IntegrationDependency func(context.Context, *testing.T) (context.Context, func())

func WithPgDB

func WithPgDB() IntegrationDependency

/ WithPgDB creates a temporary Postgres database

func WithSqliteDB

func WithSqliteDB(cfg SqliteDBConfig) IntegrationDependency

/ WithSqliteDB creates a temporary SQLite database

func WithTempDir

func WithTempDir() IntegrationDependency

/ WithTempDir creates a tempdir using the std testing lib

type SqliteDBConfig

type SqliteDBConfig struct {
	DbName   string
	DbParams string
}

Jump to

Keyboard shortcuts

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