burrowtest

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package burrowtest provides test helpers for code that uses the burrow framework. It mirrors the standard-library convention of putting test utilities in a sibling sub-package (httptest, fstest, iotest), keeping the production package's import graph free of test-only dependencies.

Importing burrowtest blank-imports the SQLite Den backend, since DB opens a SQLite database. Production binaries that do not import this package therefore do not link the SQLite engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DB

func DB(t *testing.T) *den.DB

DB returns a file-backed SQLite database wrapped in a den.DB for testing. Struct-tag validation is always-on at the Den layer. The database is created in testing.T.TempDir and closed automatically when the test finishes.

func ErrorExecContext

func ErrorExecContext(ctx context.Context) context.Context

ErrorExecContext returns a context with a minimal burrow.TemplateExecutor that renders error templates as "<code>: <message>". Use this in tests that trigger error responses through burrow.Handle or burrow.RenderError.

func ErrorExecMiddleware

func ErrorExecMiddleware(next http.Handler) http.Handler

ErrorExecMiddleware is an HTTP middleware that injects ErrorExecContext into the request context. Use this in tests that need error rendering support.

func StubApp added in v0.20.0

func StubApp(name string) burrow.App

StubApp returns a minimal burrow.App that exposes only the given name. Use it in tests to satisfy a contrib's burrow.HasDependencies declaration when the test doesn't actually exercise the depended-on contrib's behaviour.

func TempDSN added in v0.20.0

func TempDSN(t *testing.T) string

TempDSN returns a file-backed SQLite DSN under testing.T.TempDir, for tests that need to construct their own DB connection (e.g. passing --database-dsn to a cli.Command). The directory is cleaned up when the test finishes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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