testutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers for all domain packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertUsers

func InsertUsers(t *testing.T, ctx context.Context, db interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
}, userIDs ...string)

InsertUsers seeds users with deterministic emails derived from their IDs.

func NewDB

func NewDB(t *testing.T) *sqlx.DB

NewDB opens an in-memory SQLite database and runs all migrations. The database is closed automatically when the test ends.

func NewDBWithUsers

func NewDBWithUsers(t *testing.T, userIDs ...string) *sqlx.DB

NewDBWithUsers opens an in-memory SQLite database, runs migrations, and seeds users.

func WithRouteParams

func WithRouteParams(ctx context.Context, params map[string]string) context.Context

WithRouteParams attaches chi route params to the context for handler tests.

func WithUserContext

func WithUserContext(ctx context.Context, userID string) context.Context

WithUserContext attaches an authenticated user to the context for handler tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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