dbtest

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dbtest provides shared test helpers for database setup and session seeding across test packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsstMsg

func AsstMsg(
	sid string, ordinal int, content string,
) db.Message

AsstMsg creates an assistant message for the given session.

func OpenTestDB

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

OpenTestDB creates a temporary SQLite database for testing. The database is automatically closed when the test completes.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v.

func SeedMessages

func SeedMessages(t *testing.T, d *db.DB, msgs ...db.Message)

SeedMessages inserts messages into the database, failing the test on error.

func SeedSession

func SeedSession(
	t *testing.T, d *db.DB, id, project string,
	opts ...func(*db.Session),
)

SeedSession creates and upserts a session with sensible defaults. Override any field via the opts functions.

func UserMsg

func UserMsg(
	sid string, ordinal int, content string,
) db.Message

UserMsg creates a user message for the given session.

func WriteTestFile

func WriteTestFile(
	t *testing.T, path string, content []byte,
)

WriteTestFile creates a file at path with the given content, creating parent directories as needed. Fails the test on any error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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