Documentation
¶
Index ¶
- type GhostPostgres
- func (gp *GhostPostgres) ConnString() string
- func (gp *GhostPostgres) ConnStringFor(dbname string) string
- func (gp *GhostPostgres) Create() error
- func (gp *GhostPostgres) DataDir() (string, error)
- func (gp *GhostPostgres) Destroy() error
- func (gp *GhostPostgres) Init() error
- func (gp *GhostPostgres) Open() (*sql.DB, error)
- func (gp *GhostPostgres) OpenFor(dbname string) (*sql.DB, error)
- func (gp *GhostPostgres) Prepare() error
- func (gp *GhostPostgres) Start() error
- func (gp *GhostPostgres) Stop() error
- func (gp *GhostPostgres) Terminate() error
- func (gp *GhostPostgres) URL() string
- func (gp *GhostPostgres) URLFor(dbname string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GhostPostgres ¶
type GhostPostgres struct {
Host string
Port int
User string
Dbname string
InitdbArgs []string
InitdbGlobs []string
PostgresGlobs []string
TmpDir string
Prefix string
Dir string
Postgres *exec.Cmd
ConnOptions []string
Logger *log.Logger
DefaultDbname string
}
func New ¶
func New() *GhostPostgres
func (*GhostPostgres) ConnString ¶
func (gp *GhostPostgres) ConnString() string
ConnString returns a connection string for the testing database
func (*GhostPostgres) ConnStringFor ¶
func (gp *GhostPostgres) ConnStringFor(dbname string) string
ConnStringFor returns a connection string for the database with the specified name
func (*GhostPostgres) Create ¶
func (gp *GhostPostgres) Create() error
Create creates the database on the running postgres server.
func (*GhostPostgres) DataDir ¶
func (gp *GhostPostgres) DataDir() (string, error)
DataDir returns the data directory for the database.
func (*GhostPostgres) Destroy ¶
func (gp *GhostPostgres) Destroy() error
Destroy removes the directory for the database.
func (*GhostPostgres) Init ¶
func (gp *GhostPostgres) Init() error
Init runs initdb to create the PostgreSQL database.
func (*GhostPostgres) Open ¶
func (gp *GhostPostgres) Open() (*sql.DB, error)
Open opens a connection to the testing database
func (*GhostPostgres) OpenFor ¶
func (gp *GhostPostgres) OpenFor(dbname string) (*sql.DB, error)
OpenFor opens a connection to the database with the specified name
func (*GhostPostgres) Prepare ¶
func (gp *GhostPostgres) Prepare() error
Prepare returns a functioning ephemeral database or an error.
func (*GhostPostgres) Start ¶
func (gp *GhostPostgres) Start() error
Start starts the postgresql server and waits for it to become available.
func (*GhostPostgres) Stop ¶
func (gp *GhostPostgres) Stop() error
Stop stops the running postgresql server. It first tries to interrupt the process, and then kills it.
func (*GhostPostgres) Terminate ¶
func (gp *GhostPostgres) Terminate() error
Terminate stops and destroys the database.
func (*GhostPostgres) URL ¶
func (gp *GhostPostgres) URL() string
URL returns a URL string for the testing database
func (*GhostPostgres) URLFor ¶
func (gp *GhostPostgres) URLFor(dbname string) string
URLFor returns a URL string for the database with the specified name