adaptertest

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package adaptertest publishes the conformance suite used by first-party and third-party database adapters.

Index

Constants

View Source
const ReleaseUpgradeBaseline = "ecf48ac"

ReleaseUpgradeBaseline identifies the first adapter-bearing revision. The repository did not have semantic release tags when this fixture was added.

Variables

This section is empty.

Functions

func AssertReleaseUpgrade

func AssertReleaseUpgrade(t *testing.T, database betterauth.DatabaseAdapter)

AssertReleaseUpgrade proves baseline data remains available through current indexed authentication queries and current mutations.

func LegacyCoreSchema

func LegacyCoreSchema() betterauth.Schema

LegacyCoreSchema returns the frozen schema shape shipped at ReleaseUpgradeBaseline. That revision predates declarative non-unique and compound indexes but otherwise has the current core fields.

func MappedIdentitySchema added in v1.1.0

func MappedIdentitySchema() betterauth.Schema

MappedIdentitySchema returns the core schema with swapped stored names: user is stored as "account", account as "identity", session as "user", and auditEvent as "session". user.email is stored as "email_address" and account.accountId as "provider_account_id". An adapter that mixes logical and stored names stores rows in the wrong place or applies the wrong unique rules under this schema.

func ReleaseV102CoreSchema added in v1.1.0

func ReleaseV102CoreSchema() betterauth.Schema

ReleaseV102CoreSchema returns the frozen core schema shipped in better-auth-go v1.0.2. The account issuer column of unreleased main is gone again, so the current core schema matches it: a v1.0.2 database needs no migration.

func Run

func Run(t *testing.T, factory Factory)

Run executes the core Better Auth adapter contract.

func RunAccountIdentity added in v1.1.0

func RunAccountIdentity(t *testing.T, factory SchemaFactory)

RunAccountIdentity checks that accounts are keyed by (providerId, accountId), as in Better Auth 1.7.3 and later, and that a database shaped like better-auth-go v1.0.2 works with the current schema and no migration.

func RunMappedIdentity added in v1.1.0

func RunMappedIdentity(t *testing.T, factory SchemaFactory)

RunMappedIdentity checks CRUD, unique rules, ConsumeOne, and IncrementOne under MappedIdentitySchema, and that each row lands in its stored model.

func RunSchemaCheck added in v1.1.0

func RunSchemaCheck(t *testing.T, factory SchemaCheckFactory)

RunSchemaCheck runs the live schema check contract for SQL adapters.

func SeedReleaseBaseline

func SeedReleaseBaseline(t *testing.T, database betterauth.DatabaseAdapter)

SeedReleaseBaseline stores representative data in every core model using only the schema available at ReleaseUpgradeBaseline.

Types

type Factory

type Factory func(*testing.T) betterauth.DatabaseAdapter

type SchemaCheckAdapter added in v1.1.0

type SchemaCheckAdapter interface {
	betterauth.DatabaseAdapter
	betterauth.SchemaChecker
	Migrate(context.Context, betterauth.Schema) error
}

SchemaCheckAdapter is an adapter that can migrate and check its schema.

type SchemaCheckFactory added in v1.1.0

type SchemaCheckFactory func(*testing.T) SchemaCheckTarget

SchemaCheckFactory returns a fresh, empty database for each call.

type SchemaCheckTarget added in v1.1.0

type SchemaCheckTarget struct {
	Adapter SchemaCheckAdapter
	// Exec runs one raw SQL statement against the database.
	Exec func(t *testing.T, statement string)
	// Table returns the quoted table name to use in raw SQL, including any
	// schema the adapter is configured with.
	Table func(name string) string
}

SchemaCheckTarget is one fresh, empty database for the schema check suite.

type SchemaFactory added in v1.1.0

type SchemaFactory func(*testing.T, betterauth.Schema) betterauth.DatabaseAdapter

SchemaFactory returns a fresh, empty adapter that is ready for schema: its tables, collections, and indexes exist, and for a SchemaConfigurableAdapter WithSchema has been applied. It must not wrap the adapter with betterauth.WrapDatabaseAdapter; the suites do that so they can also read the stored rows by their physical names.

Jump to

Keyboard shortcuts

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