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

dbtest

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package dbtest is the database conformance suite: the same schema, ORM, transaction and migration checks run against every dialect (SQLite in core, Postgres and others in their driver modules).

func TestConformance(t *testing.T) {
	db := open(t) // *database.DB for the dialect under test
	dbtest.Run(t, db)
}

Run creates and drops its own tables (prefixed "dbt_"), so point it at a throwaway database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, db *database.DB)

Run executes the conformance suite against db. Subtests run in order and share tables, so they are not parallel.

Types

type Author

type Author struct {
	orm.Model
	orm.SoftDeletes

	Name   string
	Email  *string
	Active bool
	Score  float64
	Meta   orm.JSON[Meta]

	Books     orm.HasMany[Book] `json:"books,omitzero"`
	FirstBook orm.HasOne[Book]  `json:"first_book,omitzero" orm:"fk:author_id"`
}

Author is the main conformance model.

func (Author) Table

func (Author) Table() string

Table implements orm.Tabler.

type Book

type Book struct {
	orm.Model

	AuthorID  int64
	Title     string
	Pages     int
	Published *time.Time

	Author orm.BelongsTo[Author] `json:"author,omitzero"`
	Tags   orm.ManyToMany[Tag]   `json:"tags,omitzero"   orm:"pivot:dbt_book_tag"`
}

Book belongs to an author (foreign key with cascade).

func (Book) Table

func (Book) Table() string

Table implements orm.Tabler.

type Meta

type Meta struct {
	Tags []string `json:"tags"`
}

Meta is a JSON column payload.

type Tag added in v0.4.0

type Tag struct {
	orm.Model

	Name string `json:"name"`
}

Tag relates to books through the dbt_book_tag pivot table.

func (Tag) Table added in v0.4.0

func (Tag) Table() string

Table implements orm.Tabler.

Jump to

Keyboard shortcuts

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