test

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_DBDRIVER = "SQLIZE_TSTDB_DRIVER"
	ENV_DBSOURCE = "SQLIZE_TSTDB_SOURCE"
)
View Source
const CRUDOps = CreateOp | ReadOp | UpdateOp | DeleteOp
View Source
const OpsErrorFmt = "Expected operations %s, got %s"

Variables

This section is empty.

Functions

func DBOpen

func DBOpen(t *testing.T, opts *DBOptions) (sqlize.DB, error)

func Example

func Example()

func MustDBOpen

func MustDBOpen(t *testing.T, opts *DBOptions) sqlize.DB

func Truncate

func Truncate(db sqlize.SQL, tables ...bsq.Tabler) error

Types

type CRUDOperation

type CRUDOperation int
const (
	CreateOp CRUDOperation = (1 << iota)
	ReadOp
	UpdateOp
	DeleteOp
)

func (CRUDOperation) All

func (ops CRUDOperation) All(test CRUDOperation) bool

func (CRUDOperation) Any

func (ops CRUDOperation) Any(test CRUDOperation) bool

func (CRUDOperation) String

func (ops CRUDOperation) String() string

type CRUDTest32

type CRUDTest32 struct {
	// WriteObj is set by test code and then written to the DB
	WriteObj sqlize.Entity32
	// ReadObj is read from DB to be compared with the WriteObj
	ReadObj sqlize.Entity32
	// Chage is used to modify the WriteObj to check updates
	Change ChangeFunc
	// If Equal is not nil it is used to compare WriteObj and ReadObj. Otherwise
	// the objects are compared with reflect.DeepEqual().
	Equal func() bool
	// The DAO object to handle the CRUD operations
	Repo sqlize.Repo32
}

func (*CRUDTest32) Run

func (ct *CRUDTest32) Run(t *testing.T, db sqlize.SQL, insert bool) (res CRUDOperation)

type CRUDTest64

type CRUDTest64 struct {
	WriteObj sqlize.Entity64
	ReadObj  sqlize.Entity64
	Change   ChangeFunc
	Equal    func() bool
	Repo     sqlize.Repo64
}

func (*CRUDTest64) Run

func (ct *CRUDTest64) Run(t *testing.T, db sqlize.SQL) (res CRUDOperation)

type ChangeFunc

type ChangeFunc = func() (desc string, cont bool)

ChangeFunc is used in CRUDTests to modify the write object and see if the written change is successfully read back. Changing the write object will be repeated until the ChangeFunc retuns chainNext == nil. Otherwise chainNext will be passed to the next call of the ChangeFunc.

type DBOptions

type DBOptions struct {
	LogSQL bool
	Driver string
	Source string
}

type LogTo

type LogTo struct {
	Test *testing.T
}

func (LogTo) Connection

func (l LogTo) Connection(conn sqlize.SQL) sqlize.SQL

type Queries

type Queries struct {
	Test    *testing.T
	DB      sqlize.SQL
	Dialect bsq.Dialect
	// Note that RDBMS generally do not guarantee column order for good reasons.
	// Use this check for aesthetic reasons but DO NOT expect it for correctness.
	SameCoumnOrder bool
}

func (Queries) SelectAllColumns

func (qs Queries) SelectAllColumns(decl bsq.Tabler) (done bool)

func (Queries) SelectDeclaredColumns

func (qs Queries) SelectDeclaredColumns(decl bsq.Tabler) (done bool)

Jump to

Keyboard shortcuts

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