sqltest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpRows

func DumpRows(rows *sql.Rows)

func QueryDump

func QueryDump(dbi interface{}, qry string, args ...interface{})

Dump result of query to output

func QueryInt

func QueryInt(dbi CtxQuerier, qry string, args ...interface{}) (result int)

func QueryString

func QueryString(dbi CtxQuerier, qry string, args ...interface{}) (result string)

func QueryTime

func QueryTime(dbi CtxQuerier, qry string, args ...interface{}) (result time.Time)

Types

type CtxExecer

type CtxExecer interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

type CtxQuerier

type CtxQuerier interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

type Fixture

type Fixture struct {
	DB     *sql.DB
	DBName string
	// contains filtered or unexported fields
}

func NewFixture

func NewFixture() *Fixture

func (*Fixture) RunMigrationFile

func (f *Fixture) RunMigrationFile(filename string)

func (*Fixture) RunMigrations

func (f *Fixture) RunMigrations()

func (*Fixture) Teardown

func (f *Fixture) Teardown()

type MapRow

type MapRow map[string]interface{}

type MapRows

type MapRows []MapRow

func QueryMaps

func QueryMaps(dbi CtxQuerier, qry string, args ...interface{}) MapRows

Returns the result of a query as a loosely typed structure, for use with test code

func RowsMap

func RowsMap(columns []string, rows Rows) (outRows MapRows)

type Row

type Row []interface{}

type Rows

type Rows []Row

func Query

func Query(dbi CtxQuerier, qry string, args ...interface{}) Rows

func RowIteratorToSlice

func RowIteratorToSlice(rows *sql.Rows) (columns []string, result Rows)

type StdoutLogger

type StdoutLogger struct {
}

func (StdoutLogger) Printf

func (s StdoutLogger) Printf(format string, v ...interface{})

func (StdoutLogger) Println

func (s StdoutLogger) Println(v ...interface{})

Jump to

Keyboard shortcuts

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