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

testbuilder

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvider added in v0.8.0

func NewProvider(t *testing.T, db *sql.DB) *goose.Provider

NewProvider returns a goose provider for db that reads migrations from the filesystem, for tests that need to control how far a database is migrated.

func Schema added in v0.9.0

func Schema() *database.Schema

Schema is the schema of the repository: what main makes with the migrations that are embedded in the binary, which a test does not have, so it is made with the migrations in the directory that they are in. A test gives it to what migrates a database, since nothing finds one by itself.

func SetupDB

func SetupDB(t *testing.T) *sql.DB

SetupDB creates an in-memory SQLite database with migrations applied. The DB is closed automatically when the test completes. Apply migrations from the filesystem rather than the embedded FS which is not populated when running tests.

func SetupDBFile added in v0.9.0

func SetupDBFile(t *testing.T) (*sql.DB, string)

SetupDBFile is SetupDB for a database in a file, which is what something that opens its database by its path needs (a database that is not in memory is one for every connection, which is what lets the code that is tested open it for itself). It returns the database, for what the test puts in it, and the path to it. The file is in a directory of the test, and the database is closed when the test completes.

Types

type GameBuilder

type GameBuilder struct {
	// contains filtered or unexported fields
}

GameBuilder builds a game_install row, creating a store if one is not provided

func NewGame

func NewGame(t *testing.T, db *sql.DB) *GameBuilder

func (*GameBuilder) Build

func (b *GameBuilder) Build() dbq.GameInstall

func (*GameBuilder) NotPresent

func (b *GameBuilder) NotPresent() *GameBuilder

func (*GameBuilder) WithInstallRoot

func (b *GameBuilder) WithInstallRoot(root string) *GameBuilder

func (*GameBuilder) WithInstanceID

func (b *GameBuilder) WithInstanceID(id string) *GameBuilder

func (*GameBuilder) WithName

func (b *GameBuilder) WithName(name string) *GameBuilder

func (*GameBuilder) WithStore

func (b *GameBuilder) WithStore(storeID string) *GameBuilder

func (*GameBuilder) WithStoreGameID

func (b *GameBuilder) WithStoreGameID(id string) *GameBuilder

type ProfileBuilder

type ProfileBuilder struct {
	// contains filtered or unexported fields
}

ProfileBuilder builds a profile row for a game install.

func NewProfile

func NewProfile(t *testing.T, db *sql.DB) *ProfileBuilder

func (*ProfileBuilder) Active

func (b *ProfileBuilder) Active() *ProfileBuilder

func (*ProfileBuilder) Build

func (b *ProfileBuilder) Build() dbq.Profile

func (*ProfileBuilder) WithGame

func (b *ProfileBuilder) WithGame(gi dbq.GameInstall) *ProfileBuilder

func (*ProfileBuilder) WithName

func (b *ProfileBuilder) WithName(name string) *ProfileBuilder

type StoreBuilder

type StoreBuilder struct {
	// contains filtered or unexported fields
}

StoreBuilder builds a store row

func NewStore

func NewStore(t *testing.T, db *sql.DB) *StoreBuilder

func (*StoreBuilder) Build

func (b *StoreBuilder) Build() dbq.Store

func (*StoreBuilder) WithID

func (b *StoreBuilder) WithID(id string) *StoreBuilder

func (*StoreBuilder) WithImplementation

func (b *StoreBuilder) WithImplementation(impl string) *StoreBuilder

Jump to

Keyboard shortcuts

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