Safe Haskell | None |
---|---|
Language | Haskell2010 |
Database.Postgres.Temp
Description
This module provides functions greating a temporary postgres instance on a random port for testing.
result <-start
[] case result of Left err -> print err Right tempDB -> do -- Do stuffstop
tempDB
The are few different methods for starting postgres
which provide different
methods of dealing with stdout
and stderr
.
The start methods use a config based on the one used by pg_tmp, but can be overriden by in different values to the first argument of the start functions.
- data DB = DB {}
- data StartError
- start :: [(String, String)] -> IO (Either StartError DB)
- startAndLogToTmp :: [(String, String)] -> IO (Either StartError DB)
- startWithHandles :: [(String, String)] -> Handle -> Handle -> IO (Either StartError DB)
- stop :: DB -> IO ExitCode
Types
Constructors
DB | |
Fields
|
Starting postgres
startWithHandles
is the most general way to start postgres. It allows the user to
pass in it's own handles for stdout
and stderr
. start
and startAndLogToTmp
both call startWithHandles
passing in different handles. start
uses the current
process's stdout
and stderr
and startAndLogToTmp
logs to files in the mainDir
.
postgres
is started with a default config with the following options:
listen_addresses = '' shared_buffers = 12MB fsync = off synchronous_commit = off full_page_writes = off log_min_duration_statement = 0 log_connections = on log_disconnections = on unix_socket_directories = {mainDir} client_min_messages = ERROR
Any of the options can be overriden by passing in a different value when starting
Right db <- start
[("log_min_duration_statement", "1000")]
start postgres and use the current processes stdout and stderr
Arguments
:: [(String, String)] | Extra options which override the defaults |
-> Handle | stdout |
-> Handle | stderr |
-> IO (Either StartError DB) |
Start postgres and pass in handles for stdout and stderr