sqldrivermock

package
v0.0.0-...-c94e8e7 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sqldrivermock provides a basic null implementation of "database/sql/driver".Driver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Logf func(string, ...interface{})
	// contains filtered or unexported fields
}

Driver is a mock implementation of database/sql/driver.Driver

func New

func New(opts ...Option) *Driver

New creates a Driver

func (*Driver) Expect

func (d *Driver) Expect() *Expect

Expect is the set of expectations for the mock driver

func (*Driver) Open

func (d *Driver) Open(name string) (driver.Conn, error)

Open opens a new mock connection

type Expect

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

Expect is a series of expectations of Driver

func (*Expect) Confirm

func (e *Expect) Confirm() error

Confirm verifies that all expectations have been met

func (*Expect) Open

func (e *Expect) Open() *ExpectedConn

Open expects a call to driver.Open()

func (*Expect) String

func (e *Expect) String() string

type ExpectationMismatchError

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

ExpectationMismatchError is provided when a recorded event doesn't match expected type

func (ExpectationMismatchError) Actual

func (err ExpectationMismatchError) Actual() interface{}

Actual is the actual event

func (ExpectationMismatchError) Error

func (err ExpectationMismatchError) Error() string

func (ExpectationMismatchError) Expected

func (err ExpectationMismatchError) Expected() interface{}

Expected is the expected event

type ExpectedCommit

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

ExpectedCommit is the set of expectations for a call to driver.Tx.Commit

func (*ExpectedCommit) String

func (ec *ExpectedCommit) String() string

func (*ExpectedCommit) WillError

func (ec *ExpectedCommit) WillError(err error)

WillError provides an error that will be returned by the call to Commit

type ExpectedConn

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

ExpectedConn is the set of expecatations for a driver.Conn

func (*ExpectedConn) Begin

func (ec *ExpectedConn) Begin() *ExpectedTx

Begin expects a call to driver.Conn.Begin

func (*ExpectedConn) Prepare

func (ec *ExpectedConn) Prepare() *ExpectedStmt

Prepare expects a call to drvier.Conn.Prepare

func (*ExpectedConn) String

func (ec *ExpectedConn) String() string

func (*ExpectedConn) WillError

func (ec *ExpectedConn) WillError(err error)

WillError specifies an error that will be returned by driver.Open

func (*ExpectedConn) WithDSN

func (ec *ExpectedConn) WithDSN(dsn string) *ExpectedConn

WithDSN sets the expected DSN for the connection

type ExpectedExec

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

ExpectedExec is the set of expectations for a call to driver.Stmt.Query

func (*ExpectedExec) String

func (ee *ExpectedExec) String() string

func (*ExpectedExec) WillError

func (ee *ExpectedExec) WillError(err error)

WillError specifies an error that will be returned by Exec

func (*ExpectedExec) WithArgs

func (ee *ExpectedExec) WithArgs(args ...driver.Value) *ExpectedExec

WithArgs sets the expected set of arguments for the execution

type ExpectedQuery

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

ExpectedQuery is the set of expectations for a call to driver.Stmt.Query

func (*ExpectedQuery) String

func (eq *ExpectedQuery) String() string

func (*ExpectedQuery) WillError

func (eq *ExpectedQuery) WillError(err error)

WillError specifies an error that will be returned by Query

func (*ExpectedQuery) WithArgs

func (eq *ExpectedQuery) WithArgs(args ...driver.Value) *ExpectedQuery

WithArgs sets the expected set of arguments for the query

type ExpectedRollback

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

ExpectedRollback is the set of expectations for a call to driver.Tx.Rollback

func (*ExpectedRollback) String

func (er *ExpectedRollback) String() string

func (*ExpectedRollback) WillError

func (er *ExpectedRollback) WillError(err error)

WillError provides an error that will be returned by the call to Rollback

type ExpectedStmt

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

ExpectedStmt is the set of expectations for a driver.Stmt

func (*ExpectedStmt) Exec

func (es *ExpectedStmt) Exec() *ExpectedExec

Exec expects a call to driver.Stmt.Exec

func (*ExpectedStmt) Query

func (es *ExpectedStmt) Query() *ExpectedQuery

Query expects a call to driver.Stmt.Query

func (*ExpectedStmt) String

func (es *ExpectedStmt) String() string

func (*ExpectedStmt) WillError

func (es *ExpectedStmt) WillError(err error)

WillError specifies an error that will be returned by Prepare

func (*ExpectedStmt) WithQuery

func (es *ExpectedStmt) WithQuery(qs string) *ExpectedStmt

WithQuery sets the expected query string

type ExpectedTx

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

ExpectedTx is the set of expectations for a driver.Tx

func (*ExpectedTx) Commit

func (et *ExpectedTx) Commit() *ExpectedCommit

Commit expects a call to driver.Tx.Commit

func (*ExpectedTx) Prepare

func (et *ExpectedTx) Prepare() *ExpectedStmt

Prepare expects a call to drvier.Conn.Prepare

func (*ExpectedTx) Rollback

func (et *ExpectedTx) Rollback() *ExpectedRollback

Rollback expects a call to driver.Tx.Rollback

func (*ExpectedTx) String

func (et *ExpectedTx) String() string

func (*ExpectedTx) WillError

func (et *ExpectedTx) WillError(err error) *ExpectedTx

WillError provides an error that will be returned by the call to Begin

func (*ExpectedTx) WithOptions

func (et *ExpectedTx) WithOptions(opts driver.TxOptions) *ExpectedTx

WithOptions sets the expected TxOptions

type Option

type Option func(*Driver)

Option is a Driver option

func ConnBeginTx

func ConnBeginTx() Option

ConnBeginTx uses a driver.Conn implementation that also supports driver.ConnBeginTx

func Logf

func Logf(fn func(string, ...interface{})) Option

Logf provides a logger to Driver

Jump to

Keyboard shortcuts

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