dbfixture

package
v1.0.1904-f7dc29d Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package dbfixture will setup a and reset a fresh database for each of your tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Host     string
	User     string
	Password secret.String
}

type Fixture

type Fixture struct {
	DBName   string
	Host     string
	User     string
	Password secret.String
	DB       *sqlx.DB
	TX       *db.TxManager
	Cleanup  func(ctx context.Context) error
	// contains filtered or unexported fields
}

func SetupDB

func SetupDB(ctx context.Context, t types.TestingTB, schema string, con Connection) (db *Fixture)

func (*Fixture) Reset

func (f *Fixture) Reset(ctx context.Context) (err error)

type Manager

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

func NewManager

func NewManager(con Connection) (*Manager, error)

NewManager returns a DB manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) NewDB

func (m *Manager) NewDB(ctx context.Context, con Connection, dbName, schema string) (*Fixture, error)

NewDB returns a new database fixture. The database name is generated from dbName with a random suffix.

type NoDBError

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

func (*NoDBError) Error

func (e *NoDBError) Error() string

func (*NoDBError) Unwrap

func (e *NoDBError) Unwrap() error

type SharedFixture

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

func SetupSystem

func SetupSystem(t types.TestingTB, con Connection) *SharedFixture

SetupSystem prepares the running system for use callers should not rely on the fact this currently uses a package global

func (*SharedFixture) Manager

func (s *SharedFixture) Manager() *Manager

Jump to

Keyboard shortcuts

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