testdb

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package testdb provides the single temporary, memory-backed test database mechanism for this repository. A MemoryDatabases instance reserves a fresh main/thumbs memdb VFS pair for a caller-supplied schema key: construction materializes and restores main immediately, while ThumbsURI materializes and restores its fresh thumbs peer once on first use.

Seeds are process-local implementation state: built or rebuilt from migrations under one process-temporary root, checkpointed and normalized to rollback-journal mode, with sidecars removed. Callers receive only SQLite URIs, never file paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryDatabases

type MemoryDatabases struct {
	// contains filtered or unexported fields
}

MemoryDatabases reserves a fresh main/thumbs memdb VFS image pair for one schema key. Construction materializes main; ThumbsURI materializes thumbs once on first use. Close is idempotent and releases every materialized image.

func NewMemoryDatabases

func NewMemoryDatabases(ctx context.Context, schemaKey string) (*MemoryDatabases, error)

NewMemoryDatabases materializes a fresh main memory image for schemaKey and reserves its fresh thumbs peer. schemaKey selects only internal process-local seeds; it must not be inferred from a caller path.

func (*MemoryDatabases) Close

func (m *MemoryDatabases) Close() error

Close is idempotent: it releases every materialized image and a subsequent constructor call yields a fresh pair.

func (*MemoryDatabases) MainURI

func (m *MemoryDatabases) MainURI(readOnly bool) string

MainURI returns the already-materialized main image URI. readOnly selects the URI access mode; callers must never assemble SQLite URIs themselves.

func (*MemoryDatabases) ThumbsURI

func (m *MemoryDatabases) ThumbsURI(ctx context.Context, readOnly bool) (string, error)

ThumbsURI materializes the reserved thumbs peer once on first use and then returns the same URI. readOnly selects the URI access mode.

Jump to

Keyboard shortcuts

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