sqnil

package module
v0.0.0-...-731d52d Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 8 Imported by: 0

README

sqnil

A Go library that creates a 'nil' or fake sql driver to be used with testing packages using Go's sql package.

Warning

This library is currently in very early development so its interface and features are in a large amount of flux.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterConn

func RegisterConn(c *Conn)

Types

type Conn

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

func MustConn

func MustConn(c *Conn, err error) *Conn

func NewConn

func NewConn(opts ...ConnOption) (*Conn, error)

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) DataSourceName

func (c *Conn) DataSourceName() string

func (*Conn) DriverName

func (c *Conn) DriverName() string

func (*Conn) Ping

func (c *Conn) Ping(ctx context.Context) error

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

func (*Conn) RegisterStmt

func (c *Conn) RegisterStmt(stmt *Stmt) *Stmt

type ConnOption

type ConnOption func(*Conn)

func WithConnCloseError

func WithConnCloseError(err error) ConnOption

func WithConnLogger

func WithConnLogger(logger Logger) ConnOption

func WithConnName

func WithConnName(name string) ConnOption

func WithConnOpenError

func WithConnOpenError(err error) ConnOption

func WithConnPingError

func WithConnPingError(err error) ConnOption

type Logger

type Logger interface {
	Logf(msg string, args ...interface{})
}

type NilLogger

type NilLogger struct{}

func NewNilLogger

func NewNilLogger() *NilLogger

func (*NilLogger) Logf

func (nl *NilLogger) Logf(msg string, args ...interface{})

type Result

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

func (*Result) LastInsertId

func (r *Result) LastInsertId() (int64, error)

func (*Result) RowsAffected

func (r *Result) RowsAffected() (int64, error)

type Row

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

func NewRow

func NewRow(values ...interface{}) *Row

type Rows

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

func NewRows

func NewRows(opts ...RowsOptions) *Rows

func (*Rows) Close

func (r *Rows) Close() error

func (*Rows) Columns

func (r *Rows) Columns() []string

func (*Rows) Next

func (r *Rows) Next(dest []driver.Value) error

type RowsOptions

type RowsOptions func(*Rows)

func WithRowsColumns

func WithRowsColumns(columns ...string) RowsOptions

func WithRowsValues

func WithRowsValues(values ...*Row) RowsOptions

type StdoutLogger

type StdoutLogger struct{}

func NewStdoutLogger

func NewStdoutLogger() *StdoutLogger

func (*StdoutLogger) Logf

func (sl *StdoutLogger) Logf(msg string, args ...interface{})

type Stmt

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

func NewStmt

func NewStmt(opts ...StmtOption) *Stmt

func (*Stmt) Close

func (s *Stmt) Close() error

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

func (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)

type StmtOption

type StmtOption func(*Stmt)

func WithStmtCloseError

func WithStmtCloseError(err error) StmtOption

func WithStmtExecError

func WithStmtExecError(err error) StmtOption

func WithStmtExecResult

func WithStmtExecResult(result *Result) StmtOption

func WithStmtPrepareError

func WithStmtPrepareError(err error) StmtOption

func WithStmtQueryError

func WithStmtQueryError(err error) StmtOption

func WithStmtQueryRows

func WithStmtQueryRows(rows *Rows) StmtOption

type Tx

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

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Rollback

func (t *Tx) Rollback() error

Jump to

Keyboard shortcuts

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