dbtest

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dbtest has utilities to help with writing DB related tests in conjunction with sqlize.

Index

Constants

View Source
const (
	ENV_DBDRIVER = "SQLIZE_TSTDB_DRIVER"
	ENV_DBSOURCE = "SQLIZE_TSTDB_SOURCE"
)

Variables

This section is empty.

Functions

func DriverName

func DriverName(t interface{ Error(args ...any) }, fallback string) string

func NewLogger

func NewLogger(t interface{ Logf(string, ...any) }) sqlize.Logger

NewLogger creates a new logger to be used with sqlize.LogDriver. For an example read the test TestNewLogger.

func Open

func Open(t *testing.T, drv driver.Driver, source string, log sqlize.LogFlag) (*sql.DB, error)

func OpenArgs

func OpenArgs(t interface{ Error(args ...any) }, drvFallback, srcFallback string) (driver, source string)

func ShallOpen added in v0.8.3

func ShallOpen(t *testing.T, drv driver.Driver, source string, log sqlize.LogFlag) *sql.DB

func SourceName

func SourceName(t interface{ Error(args ...any) }, fallback string) string

func VerifyTable

func VerifyTable(t testing.TB, q sqlize.Querier, def bsq.TableDef) (ok bool)

func VerifyTables

func VerifyTables(t testing.TB, q sqlize.Querier) (ok bool)

Types

type CRUDTest

type CRUDTest[E entity.Entity[I], I entity.ID] struct {
	Repo         entity.Repo[E, I]
	Create, Read E
	Equal        func(e, f E) bool
	// contains filtered or unexported fields
}

func (CRUDTest[E, I]) Run

func (crud CRUDTest[E, I]) Run(t *testing.T, db sqlize.Querier)

func (CRUDTest[E, I]) Update

func (crud CRUDTest[E, I]) Update(name string, mod func(E)) CRUDTest[E, I]

type Errorer

type Errorer struct{ W io.Writer }

func Example

func Example() Errorer

func (Errorer) Error

func (e Errorer) Error(args ...any)

Jump to

Keyboard shortcuts

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