Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when an entity cannot be found. ErrNotFound = errors.Wrap(surf.ErrNotFound, "sql") // ErrConstraint is returned when an operation cannot be completed due // to declared constrained. ErrConstraint = errors.Wrap(surf.ErrConstraint, "sql") )
Functions ¶
func ClonePostgres ¶
ClonePostgres creates clone of given database.
While this may speedup tests that require bootstraping with a lot of fixtures, be aware that content layout on the hard drive may differ from origin and default ordering may differ from original database.
func EnsurePostgres ¶
EnsurePostgres connects to PostgreSQL instance, create database and return connection to it. If connection to Postres cannot be established, test is skipped.
Unless option is provided, defaults are used:
- Database name: test_database_<creation time in unix ns>
- Host: localhost
- Port: 5432
- SSLMode: disable
- User: postgres
Function connects to 'postgres' database first to create new database.
Types ¶
type Database ¶
type Database interface { ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) Row BeginTx(ctx context.Context, opts *sql.TxOptions) (Transaction, error) Close() error }
func PostgresDatabase ¶
type Transaction ¶
type Transaction interface { ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) Row Commit() error Rollback() error }
Click to show internal directories.
Click to hide internal directories.