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 ¶
- func AssertCount(t testing.TB, ctx context.Context, executor database.Executor, ...)
- func AssertExists(t testing.TB, ctx context.Context, executor database.Executor, ...)
- func AssertMissing(t testing.TB, ctx context.Context, executor database.Executor, ...)
- func AssertSoftDeleted(t testing.TB, ctx context.Context, executor database.Executor, ...)
- func AssertStatementShapes(t testing.TB, scope *database.StatementScope)
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.