Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecCloser ¶
ExecCloser implements the Execer interface with an additional Close method. Using this will allow you to test simple uses of sql.DB in a service.
type Execer ¶
type Execer interface { Exec(query string, args ...interface{}) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
Execer is an interface that both sql.Tx and sql.DB implement. Using this interface will allow you to pass either into a function.
type MockRow ¶
type MockRow []interface{}
MockRow is database row that implements Row to help test applications using database/sql.
type MockRows ¶
MockRows is a set of database rows that implements Rows to help test applications using database/sql.
func NewMockRows ¶
NewMockRows will create a new MockRows instance with the given MockRow set.
func (*MockRows) Close ¶
Close will set the Close flag in MockRows so users can verify the method gets called.
type Row ¶
type Row interface {
Scan(dest ...interface{}) error
}
Row is an interface implemented by sql.Row, sql.Rows, and MockRow.
type TypeError ¶
type TypeError struct { Expected string Got interface{} }
TypeError is returned by MockRow.Scan when the type it's attempting to scan into does not match the type in the MockRow.
func NewTypeError ¶
NewTypeError returns a TypeError instance. This can helpful to use when testing for errors while scanning from databases.