Help us shape the future of Go! Take the 2026 Go Developer Survey

dbassert

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package dbassert asserts persisted state through typed query callbacks. Assertions only read through the supplied executor, usually the test's own transaction; they never reset, truncate or seed data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCount

func AssertCount(t testing.TB, ctx context.Context, executor database.Executor, count func(context.Context, database.Executor) (int64, error), want int64)

AssertCount requires exactly want rows matched by count. Pass a typed closure calling orm.Count, or a row result's Count method.

func AssertExists

func AssertExists(t testing.TB, ctx context.Context, executor database.Executor, exists func(context.Context, database.Executor) (bool, error))

AssertExists requires at least one row matched by exists. Pass a typed closure calling orm.Exists, or a row result's Exists method.

func AssertMissing

func AssertMissing(t testing.TB, ctx context.Context, executor database.Executor, count func(context.Context, database.Executor) (int64, error))

AssertMissing requires that count matches no rows. Soft-deleted rows are invisible to an ordinary ORM query; use AssertSoftDeleted for them. Pass a typed closure calling orm.Count, or a row result's Count method.

func AssertSoftDeleted

func AssertSoftDeleted(t testing.TB, ctx context.Context, executor database.Executor, count func(context.Context, database.Executor) (int64, error), existsTrashed func(context.Context, database.Executor) (bool, error))

AssertSoftDeleted requires that rows exist only as soft-deleted rows. Count must read the ordinary query; existsTrashed must read its OnlyTrashed variant. Both callbacks retain the same model filters and supplied executor.

func AssertStatementShapes

func AssertStatementShapes(t testing.TB, scope *database.StatementScope)

AssertStatementShapes asserts a completed test scope stayed within its configured per-shape threshold. Shape or call-site capacity overflow fails rather than silently passing incomplete observations. Close all query rows before asserting. Example: ctx,scope := detector.Begin(t.Context()); run(ctx); dbassert.AssertStatementShapes(t,scope).

Types

This section is empty.

Jump to

Keyboard shortcuts

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