testutil

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package testutil provides reusable test helpers for OpenTrace packages. It centralises common setup patterns (in-memory SQLite, test stores) so that every test package does not need its own copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminUser

func AdminUser() *store.User

AdminUser returns a test admin user.

func MemberUser

func MemberUser() *store.User

MemberUser returns a test non-admin user.

func SetupTestBunDB

func SetupTestBunDB(t *testing.T) *bun.DB

SetupTestBunDB opens an in-memory SQLite database (bun) with all migrations applied. The database is automatically closed when the test completes.

func SetupTestDB

func SetupTestDB(t *testing.T) *sql.DB

SetupTestDB opens an in-memory SQLite database with all migrations applied. Returns the underlying *sql.DB for backward compatibility. The database is automatically closed when the test completes.

func SetupTestStores

func SetupTestStores(t *testing.T) (*sql.DB, store.Stores)

SetupTestStores creates a full Stores instance backed by an in-memory SQLite database and a temp-directory segmented log store.

func WithAdmin

func WithAdmin(req *http.Request) *http.Request

WithAdmin injects an admin user into the request context.

func WithUser

func WithUser(req *http.Request, user *store.User) *http.Request

WithUser injects a user into the request context for testing.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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