Documentation
¶
Overview ¶
Package adaptertest publishes the conformance suite used by first-party and third-party database adapters.
Index ¶
- Constants
- func AssertReleaseUpgrade(t *testing.T, database betterauth.DatabaseAdapter)
- func LegacyCoreSchema() betterauth.Schema
- func MappedIdentitySchema() betterauth.Schema
- func ReleaseV102CoreSchema() betterauth.Schema
- func Run(t *testing.T, factory Factory)
- func RunAccountIdentity(t *testing.T, factory SchemaFactory)
- func RunMappedIdentity(t *testing.T, factory SchemaFactory)
- func RunSchemaCheck(t *testing.T, factory SchemaCheckFactory)
- func SeedReleaseBaseline(t *testing.T, database betterauth.DatabaseAdapter)
- type Factory
- type SchemaCheckAdapter
- type SchemaCheckFactory
- type SchemaCheckTarget
- type SchemaFactory
Constants ¶
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 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.