pgengine

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetInstance added in v0.7.0

func ResetInstance(ctx context.Context, db *sql.DB) error

ResetInstance attempts to reset the cluster to a clean state. It deletes all cluster level objects, i.e., roles, which are not deleted by dropping database(s). This can be useful for re-using a cluster for multiple tests.

Types

type ConnectionOption

type ConnectionOption string
const (
	ConnectionOptionDatabase ConnectionOption = "dbname"
)

type ConnectionOptions

type ConnectionOptions map[ConnectionOption]string

func (ConnectionOptions) ToDSN

func (c ConnectionOptions) ToDSN() string

func (ConnectionOptions) With

type DB

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

func (*DB) DropDB

func (d *DB) DropDB() error

DropDB drops the database

func (*DB) GetConnOpts

func (d *DB) GetConnOpts() ConnectionOptions

func (*DB) GetDSN

func (d *DB) GetDSN() string

func (*DB) GetName

func (d *DB) GetName() string

type Engine

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

func StartEngine

func StartEngine() (*Engine, error)

StartEngine starts a postgres instance. This is useful for testing, where Postgres databases need to be spun up. "postgres" must be on the system's PATH, and the binary must be located in a directory containing "initdb"

func StartEngineUsingPgDir

func StartEngineUsingPgDir(pgDir string) (_ *Engine, retErr error)

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) CreateDatabase

func (e *Engine) CreateDatabase() (*DB, error)

func (*Engine) CreateDatabaseWithName

func (e *Engine) CreateDatabaseWithName(name string) (*DB, error)

func (*Engine) GetPostgresDatabaseConnOpts

func (e *Engine) GetPostgresDatabaseConnOpts() ConnectionOptions

func (*Engine) GetPostgresDatabaseDSN

func (e *Engine) GetPostgresDatabaseDSN() string

Jump to

Keyboard shortcuts

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