sqlite

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sqlite provides shared SQLite fixtures and typed SQLX result verification for dependency-light data-driven tests.

Index

Constants

View Source
const DatlyJobsSchema = `` /* 640-byte string literal not displayed */

DatlyJobsSchema is the original DATLY_JOBS column set, adapted only for SQLite storage types. Schema creation is explicit; existing tables are never migrated.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	DB      *sql.DB
	TempDir string
	// contains filtered or unexported fields
}

func New

func New(t testing.TB, opts ...Option) *Harness

func (*Harness) AssertQuery

func (h *Harness) AssertQuery(t testing.TB, ctx context.Context, query Query, expected any)

AssertQuery reads typed rows through SQLX and compares them in query order. Expected must be a slice of structs or pointers to structs. Specify ORDER BY in the query when deterministic ordering is part of the assertion.

func (*Harness) ExecStatements

func (h *Harness) ExecStatements(ctx context.Context, statements ...string) error

func (*Harness) FaultDB

func (h *Harness) FaultDB(t testing.TB, before func(context.Context, sqlfault.Call) error) *sql.DB

func (*Harness) LoadSQLFile

func (h *Harness) LoadSQLFile(ctx context.Context, path string) error

func (*Harness) ObserveWrites

func (h *Harness) ObserveWrites(t testing.TB, ctx context.Context, table string) *atomic.Int64

ObserveWrites counts actual changes to one business table, including changes subsequently rolled back. Use a one-connection pool; allocator metadata and zero-row INSERT statements do not produce table update events.

func (*Harness) ReadQuery

func (h *Harness) ReadQuery(ctx context.Context, query Query, sliceType reflect.Type) (any, error)

ReadQuery returns a typed slice for tests that need additional assertions. SQLX remains the row-mapping owner; this harness only collects its typed rows.

type Option

type Option func(*config)

func WithDSN

func WithDSN(dsn string) Option

type Query

type Query struct {
	SQL  string
	Args []any
}

Query keeps a verification statement and its bound arguments together.

Jump to

Keyboard shortcuts

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