testutil

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides helpers for setting up test infrastructure.

Index

Constants

View Source
const TestJWTSecret = "test-jwt-secret"

TestJWTSecret is the shared secret used to sign JWTs in tests.

Variables

This section is empty.

Functions

func NewTestDB

func NewTestDB(t *testing.T) *db.DB

NewTestDB returns a fully migrated in-memory SQLite database. The connection is closed automatically when the test ends.

Uses a named shared-cache in-memory database so that multiple connections within the same test all share the same schema and data, avoiding the per-connection isolation of plain ":memory:" SQLite databases.

func SignJWT

func SignJWT(userID string) string

SignJWT signs a JWT with TestJWTSecret and the given subject (user ID). The token is valid for 5 minutes — long enough for any test.

Types

This section is empty.

Jump to

Keyboard shortcuts

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