testutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared, dependency-light helpers for tests across the mnemos packages: a migrated temp database, file creation, a silent logger, and a working-directory switch. It imports only internal/storage, so white-box (internal) test packages such as internal/ingest can use it without creating an import cycle. Corpus building (which needs internal/ingest) is deliberately left to the packages that need it, to keep this package cycle-free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

func Chdir(t *testing.T, dir string)

Chdir switches into dir for the duration of the test, restoring the previous working directory on cleanup.

func DiscardLogger

func DiscardLogger() *slog.Logger

DiscardLogger returns a slog logger that writes nowhere, keeping test output clean while still exercising logging code paths.

func NewDB

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

NewDB opens a fresh migrated SQLite database under a per-test temp directory and registers its close on cleanup. It is the canonical replacement for the per-package "open temp migrated db" helpers.

func WriteFile

func WriteFile(t *testing.T, dir, rel, content string) string

WriteFile writes content to dir/rel, creating parent directories, and returns the absolute path written.

Types

This section is empty.

Jump to

Keyboard shortcuts

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