packages feed

tmp-postgres 1.7.0.1 → 1.7.1.0

raw patch · 7 files changed

+522/−222 lines, 7 filesdep −eitherdep −postgresql-libpq

Dependencies removed: either, postgresql-libpq

Files

+ CHANGELOG.md view
@@ -0,0 +1,4 @@+Changelog for tmp-postgres++1.7.1.0+  #35 Add Lenses for configuration
README.md view
@@ -2,37 +2,47 @@ [![Travis CI Status](https://travis-ci.org/jfischoff/tmp-postgres.svg?branch=master)](http://travis-ci.org/jfischoff/tmp-postgres) # tmp-postgres -`tmp-postgres` provides functions creating a temporary `postgres` instance.-By default it will create a temporary directory for the data,-a random port for listening and a temporary directory for a UNIX-domain socket.+`tmp-postgres` provides functions for creating a temporary `postgres` instance.+By default it will create a temporary data directory and+a temporary directory for a UNIX domain socket for `postgres` to listen on.  Here is an example using the expection safe 'with' function:  ```haskell- with $ \db -> bracket (connectPostgreSQL (toConnectionString db)) close $ \conn ->-  execute_ conn "CREATE TABLE foo (id int)"+with $ \db -> bracket+  (connectPostgreSQL (toConnectionString db))+  close $+  \conn -> PG.execute_ conn "CREATE TABLE foo (id int)" ```  To extend or override the defaults use `withConfig` (or `startConfig`). -`tmp-postgres` ultimately calls `initdb`, `postgres` and `createdb`.+`tmp-postgres` ultimately calls (optionally) `initdb`, `postgres` and+(optionally) `createdb`.+ All of the command line, environment variables and configuration files that are generated by default for the respective executables can be-extended or overrided.+extended. -All `tmp-postgres` by default is most useful for creating tests by-configuring "tmp-postgres" differently it can be used for other purposes.+In general `tmp-postgres` is useful if you want a clean temporary+`postgres` and do not want to worry about clashing with an existing+postgres instance (or needing to ensure `postgres` is already running). -* By disabling `initdb` and `createdb` one could run a temporary-postgres on a base backup to test a migration.-* By using the `stopPostgres` and `withRestart` functions one can test+Here are some different use cases for `tmp-postgres` and their respective+configurations:++* The default 'with' and 'start' functions can be used to make a sandboxed+temporary database for testing.+* By disabling `initdb` one could run a temporary+isolated postgres on a base backup to test a migration.+* By using the 'stopPostgres' and 'withRestart' functions one can test backup strategies. -The level of custom configuration is extensive but with great power comes-ability to screw everything up. `tmp-postgres` doesn't validate any custom-configuration and one can easily create a `Config` that would not allow-postgres to start.+WARNING!!+Ubuntu's PostgreSQL installation does not put `initdb` on the `PATH`. We need to add it manually.+The necessary binaries are in the `\/usr\/lib\/postgresql\/VERSION\/bin\/` directory, and should be added to the `PATH`++ > echo "export PATH=$PATH:/usr/lib/postgresql/VERSION/bin/" >> /home/ubuntu/.bashrc  # Installation 
src/Database/Postgres/Temp.hs view
@@ -16,13 +16,16 @@  @tmp-postgres@ ultimately calls (optionally) @initdb@, @postgres@ and (optionally) @createdb@.+ All of the command line, environment variables and configuration files that are generated by default for the respective executables can be-extended or overrided.+extended. -In general @tmp-postgres@ is useful if you want a temporary-@postgres@ which will not clash with open ports.-Here are some different use cases for @tmp-postgres@ and there respective+In general @tmp-postgres@ is useful if you want a clean temporary+@postgres@ and do not want to worry about clashing with an existing+postgres instance (or needing to ensure @postgres@ is already running).++Here are some different use cases for @tmp-postgres@ and their respective configurations:  * The default 'with' and 'start' functions can be used to make a sandboxed@@ -32,11 +35,6 @@ * By using the 'stopPostgres' and 'withRestart' functions one can test backup strategies. -The level of custom configuration is extensive but with great power comes the-ability to screw everything up. @tmp-postgres@ doesn't validate any custom-configuration and one can easily create a 'Config' that would not allow-@postgres@ to start.- WARNING!! Ubuntu's PostgreSQL installation does not put @initdb@ on the @PATH@. We need to add it manually. The necessary binaries are in the @\/usr\/lib\/postgresql\/VERSION\/bin\/@ directory, and should be added to the @PATH@@@ -48,7 +46,6 @@ module Database.Postgres.Temp   (   -- * Exception safe interface-  -- $options     with   , withConfig   -- * Separate start and stop interface.@@ -66,8 +63,6 @@   , withRestart   -- * Reloading the config   , reloadConfig-  -- * Errors-  , StartError (..)   -- * Main resource handle   , DB   -- ** 'DB' manipulation@@ -75,86 +70,59 @@   , toConnectionString   , toConnectionOptions   , toDataDirectory-  -- * Configuration Types+  , makeDataDirPermanent+  -- * Monoidial Configuration Types+  -- ** 'Config'   , Config (..)   , prettyPrintConfig-  -- ** Directory configuration-  , DirectoryType (..)-  , PartialDirectoryType (..)-  -- ** Listening socket configuration-  , SocketClass (..)-  , PartialSocketClass (..)-  -- ** An environment variables monoid+    -- *** 'Config' Lenses+  , configPlanL+  , configSocketL+  , configDataDirL+  , configPortL+  -- ** 'PartialPlan'+  , PartialPlan (..)+  -- *** 'PartialPlan' lenses+  , partialPlanConfigL+  , partialPlanCreateDbL+  , partialPlanDataDirectoryL+  , partialPlanInitDbL+  , partialPlanLoggerL+  , partialPlanPostgresL+  -- ** 'PartialPostgresPlan'+  , PartialPostgresPlan (..)+  -- *** 'PartialPostgresPlan' lenses+  , partialPostgresPlanClientConfigL+  , partialPostgresPlanProcessConfigL+  -- ** 'PartialProcessConfig'+  , PartialProcessConfig (..)+  -- *** 'PartialProcessConfig' Lenses+  , partialProcessConfigCmdLineL+  , partialProcessConfigEnvVarsL+  , partialProcessConfigStdErrL+  , partialProcessConfigStdInL+  , partialProcessConfigStdOutL+  -- ** 'PartialEnvVars'   , PartialEnvVars (..)-  -- ** An command line monoid+  -- *** 'PartialEnvVars' Lenses+  , partialEnvVarsInheritL+  , partialEnvVarsSpecificL+  -- ** 'PartialCommandLineArgs'   , PartialCommandLineArgs (..)-  -- ** Process configuration-  , PartialProcessConfig (..)-  , ProcessConfig (..)-  -- ** @postgres@ process configuration-  , PartialPostgresPlan (..)-  , PostgresPlan (..)-  -- *** @postgres@ process handle. Includes the client options for connecting-  , PostgresProcess (..)-  -- ** Database plans. This is used to call @initdb@, @postgres@ and @createdb@-  , PartialPlan (..)-  , Plan (..)+  -- *** 'PartialCommandLineArgs' Lenses+  , partialCommandLineArgsIndexBasedL+  , partialCommandLineArgsKeyBasedL+  -- ** 'PartialDirectoryType'+  , PartialDirectoryType (..)+  -- ** 'PartialSocketClass'+  , PartialSocketClass (..)+  -- ** 'Logger'+  , Logger+  -- * Internal events passed to the 'partialPlanLogger' .+  , Event (..)+    -- * Errors+  , StartError (..)   ) where import Database.Postgres.Temp.Internal import Database.Postgres.Temp.Internal.Core import Database.Postgres.Temp.Internal.Partial---{- $options-- Based on the value of 'configSocket' a \"postgresql.conf\" is created with-- @-   listen_addresses = \'IP_ADDRESS\'- @-- if it is 'IpSocket'. If is 'UnixSocket' then the lines-- @-   listen_addresses = ''-   unix_socket_directories = SOCKET_DIRECTORY- @-- are added. This occurs as a side effect of calling 'withConfig'.--'defaultConfig' appends the following config by default-- @-   shared_buffers = 12MB-   fsync = off-   synchronous_commit = off-   full_page_writes = off-   log_min_duration_statement = 0-   log_connections = on-   log_disconnections = on-   client_min_messages = ERROR- @--To append additional lines to \"postgresql.conf\" file create a-custom 'Config' like the following.-- @-  let custom = defaultConfig <> mempty-        { configPlan = mempty-          { partialPlanConfig =-              [ "wal_level=replica"-              , "archive_mode=on"-              , "max_wal_senders=2"-              , "fsync=on"-              , "synchronous_commit=on"-              ]-          }-        }- @-- This is common enough there is `defaultPostgresConf` which- is a helper to do this.-- As an alternative to using 'defaultConfig' one could create a- config from connections parameters using 'optionsToDefaultConfig'--}
src/Database/Postgres/Temp/Internal.hs view
@@ -4,17 +4,19 @@ identifiers that are used for testing but are not exported. -} module Database.Postgres.Temp.Internal where+ import Database.Postgres.Temp.Internal.Core import Database.Postgres.Temp.Internal.Partial-import Control.Exception-import Control.Monad (void)-import qualified Database.PostgreSQL.Simple.Options as Client-import System.Exit (ExitCode(..))-import Data.ByteString (ByteString)-import Control.Monad.Trans.Cont-import qualified Database.PostgreSQL.Simple as PG++import           Control.Exception+import           Control.Monad (void)+import           Control.Monad.Trans.Cont+import           Data.ByteString (ByteString) import qualified Data.Map.Strict as Map-import Text.PrettyPrint.ANSI.Leijen hiding ((<$>))+import qualified Database.PostgreSQL.Simple as PG+import qualified Database.PostgreSQL.Simple.Options as Client+import           System.Exit (ExitCode(..))+import           Text.PrettyPrint.ANSI.Leijen hiding ((<$>))  -- | Handle for holding temporary resources, the @postgres@ process handle --   and postgres connection information. The 'DB' also includes the@@ -55,6 +57,22 @@ --   specified explicitly when creating the 'Config' toDataDirectory :: DB -> FilePath toDataDirectory =  toFilePath . resourcesDataDir . dbResources++{-|+Make the data directory permanent. Useful for debugging.+If you are using 'with' or 'withConfig' this function will+not modify the 'DB' that is passed for cleanup. You will+need to setup your own bracket like++ @+    bracket (fmap 'makeDataDirPermanent' 'start') (either mempty 'stop')+ @++-}+makeDataDirPermanent :: DB -> DB+makeDataDirPermanent db = db+  { dbResources = makeResourcesDataDirPermanent $ dbResources db+  } ------------------------------------------------------------------------------- -- Life Cycle Management -------------------------------------------------------------------------------@@ -77,6 +95,7 @@    It will create a temporary directory for the data and a temporary directory  for a unix socket on a random port.  Additionally it will use append the following onto the \"postgresql.conf\"+ which is optimized for performance.   @    shared_buffers = 12MB@@ -95,13 +114,48 @@ 'defaultConfig' and overwrite fields or combine a 'defaultConfig' with another 'Config'  using '<>' ('mappend'). - Alternatively you can eschew 'defaultConfig' altogether, however- your @postgres@ might start and run faster if you use- 'defaultConfig'.+Alternatively you can eschew 'defaultConfig' altogether, however+your @postgres@ might start and run faster if you use+'defaultConfig'. - 'defaultConfig' also sets the 'partialPlanInitDb' to-  'pure' 'standardProcessConfig' and-  'partialPostgresPlanProcessConfig' to 'standardProcessConfig'.+'defaultConfig' also sets the 'partialPlanInitDb' to+'pure' 'standardProcessConfig' and+'partialPostgresPlanProcessConfig' to 'standardProcessConfig'.++To append additional lines to \"postgresql.conf\" file create a+custom 'Config' like the following.++ @+  custom = defaultConfig <> mempty+    { configPlan = mempty+      { partialPlanConfig =+          [ "wal_level = replica"+          , "archive_mode = on"+          , "max_wal_senders = 2"+          , "fsync = on"+          , "synchronous_commit = on"+          ]+      }+    }+ @++Or using the provided lenses and your favorite lens library++ @+  custom = defaultConfig & 'configPlanL' . 'partialPlanConfigL' <>~+    [ "wal_level = replica"+    , "archive_mode = on"+    , "max_wal_senders = 2"+    , "fsync = on"+    , "synchronous_commit = on"+    ]+ @++ This is common enough there is `defaultPostgresConf` which+ is a helper to do this.++ As an alternative to using 'defaultConfig' one could create a+ config from connections parameters using 'optionsToDefaultConfig' -} defaultConfig :: Config defaultConfig = mempty@@ -153,7 +207,7 @@           -> IO (Either StartError DB) startConfig extra = try $ evalContT $ do   dbResources@Resources {..} <--    ContT $ bracketOnError (setupConfig extra) cleanupResources+    ContT $ bracketOnError (setupConfig extra) cleanupConfig   dbPostgresProcess <-     ContT $ bracketOnError (startPlan resourcesPlan) stopPostgresProcess   pure DB {..}@@ -168,7 +222,7 @@ stop :: DB -> IO () stop DB {..} = do   void $ stopPostgresProcess dbPostgresProcess-  cleanupResources dbResources+  cleanupConfig dbResources  -- | Only stop the @postgres@ process but leave any temporary resources. --   Useful for testing backup strategies when used in conjunction with@@ -196,11 +250,27 @@ ------------------------------------------------------------------------------- -- Exception safe interface ---------------------------------------------------------------------------------- | Exception safe default database create. Takes an @action@ continuation---   which is given a 'DB' it can use to connect---   to (see 'toConnectionString' or 'postgresProcessClientOptions').---   All of the database resources are automatically cleaned up on---   completion even in the face of exceptions.+{-|+Exception safe default database create. Takes an @action@ continuation+which is given a 'DB' it can use to connect+to (see 'toConnectionString' or 'postgresProcessClientOptions').+All of the database resources are automatically cleaned up on+completion even in the face of exceptions.+Based on the value of 'configSocket' a \"postgresql.conf\" is created with++ @+   listen_addresses = \'IP_ADDRESS\'+ @++ if it is 'IpSocket'. If is 'UnixSocket' then the lines++ @+   listen_addresses = ''+   unix_socket_directories = SOCKET_DIRECTORY+ @++are added. This occurs as a side effect of calling 'withConfig'.+-} withConfig :: Config          -- ^ @extraConfiguration@. Combined with the generated 'Config'. See          -- 'startConfig' for more info
src/Database/Postgres/Temp/Internal/Core.hs view
@@ -5,23 +5,24 @@ See 'startPlan' for more details. -} module Database.Postgres.Temp.Internal.Core where-import qualified Database.PostgreSQL.Simple.Options as Client-import qualified Database.PostgreSQL.Simple as PG-import System.Process.Internals-import System.Exit (ExitCode(..))-import Data.String-import System.Posix.Signals (sigINT, signalProcess)-import Control.Exception-import Data.Foldable (for_)-import Control.Concurrent.Async (race_)-import Control.Monad (forever, (>=>))-import Control.Concurrent (threadDelay)-import Data.Typeable-import System.IO-import System.Process-import Data.Monoid-import Text.PrettyPrint.ANSI.Leijen hiding ((<$>))++import           Control.Concurrent (threadDelay)+import           Control.Concurrent.Async (race_)+import           Control.Exception+import           Control.Monad (forever, (>=>)) import qualified Data.ByteString.Char8 as BSC+import           Data.Foldable (for_)+import           Data.Monoid+import           Data.String+import           Data.Typeable+import qualified Database.PostgreSQL.Simple as PG+import qualified Database.PostgreSQL.Simple.Options as Client+import           System.Exit (ExitCode(..))+import           System.IO+import           System.Posix.Signals (sigINT, signalProcess)+import           System.Process+import           System.Process.Internals+import           Text.PrettyPrint.ANSI.Leijen hiding ((<$>))  -- | Internal events for debugging data Event@@ -109,6 +110,10 @@     , std_in  = UseHandle processConfigStdIn     , env     = Just processConfigEnvVars     }++-- | Stop a 'ProcessHandle'. An alias for 'waitForProcess'+stopProcess :: ProcessHandle -> IO ExitCode+stopProcess = waitForProcess  -- | Start a process and block until it finishes return the 'ExitCode'. executeProcess
src/Database/Postgres/Temp/Internal/Partial.hs view
@@ -13,27 +13,29 @@     functions. |-} module Database.Postgres.Temp.Internal.Partial where+ import Database.Postgres.Temp.Internal.Core-import qualified Database.PostgreSQL.Simple.Options as Client-import GHC.Generics (Generic)-import Data.Monoid.Generic-import Data.Monoid-import Data.Typeable-import System.IO-import System.Environment-import Data.Maybe-import Control.Exception-import System.IO.Temp (createTempDirectory)-import Network.Socket.Free (getFreePort)-import Control.Monad (join)-import System.Directory-import Control.Applicative.Lift-import Control.Monad.Trans.Cont-import Control.Monad.Trans.Class-import System.IO.Error-import Data.Map.Strict (Map)++import           Control.Applicative.Lift+import           Control.Exception+import           Control.Monad (join)+import           Control.Monad.Trans.Class+import           Control.Monad.Trans.Cont import qualified Data.Map.Strict as Map-import Text.PrettyPrint.ANSI.Leijen hiding ((<$>))+import           Data.Map.Strict (Map)+import           Data.Maybe+import           Data.Monoid+import           Data.Monoid.Generic+import           Data.Typeable+import qualified Database.PostgreSQL.Simple.Options as Client+import           GHC.Generics (Generic)+import           Network.Socket.Free (getFreePort)+import           System.Directory+import           System.Environment+import           System.IO+import           System.IO.Error+import           System.IO.Temp (createTempDirectory)+import           Text.PrettyPrint.ANSI.Leijen hiding ((<$>))  prettyMap :: (Pretty a, Pretty b) => Map a b -> Doc prettyMap theMap =@@ -229,6 +231,11 @@     Permanent x -> text "Permanent" <+> pretty x     Temporary x -> text "Temporary" <+> pretty x +makePermanent :: DirectoryType -> DirectoryType+makePermanent = \case+  Temporary x -> Permanent x+  x -> x+ -- | The monoidial version of 'DirectoryType'. Used to combine overrides with --   defaults when creating a 'DirectoryType'. The monoid instance treats --   'PTemporary' as 'mempty' and takes the last 'PPermanent' value.@@ -353,7 +360,8 @@   IpSocket   {}  -> pure ()   UnixSocket dir -> cleanupDirectoryType dir --- | PartialPostgresPlan+-- | @postgres@ process config and corresponding client connection+--   'Client.Options'. data PartialPostgresPlan = PartialPostgresPlan   { partialPostgresPlanProcessConfig :: PartialProcessConfig   -- ^ Monoid for the @postgres@ ProcessConfig.@@ -472,6 +480,13 @@     <>  text "resourcesDataDir:"     <+> pretty resourcesDataDir +-- | Make the 'resourcesDataDir' 'Permanent' so it will not+--   get cleaned up.+makeResourcesDataDirPermanent :: Resources -> Resources+makeResourcesDataDirPermanent r = r+  { resourcesDataDir = makePermanent $ resourcesDataDir r+  }+ -- | The high level options for overriding default behavior. data Config = Config   { configPlan    :: PartialPlan@@ -585,8 +600,8 @@   pure Resources {..}  -- | Free the temporary resources created by 'setupConfig'-cleanupResources :: Resources -> IO ()-cleanupResources Resources {..} = do+cleanupConfig :: Resources -> IO ()+cleanupConfig Resources {..} = do   cleanupSocketConfig resourcesSocket   cleanupDirectoryType resourcesDataDir -------------------------------------------------------------------------------@@ -653,3 +668,254 @@ hostToSocketClass hostOrSocketPath = case hostOrSocketPath of   '/' : _ -> PUnixSocket $ PPermanent hostOrSocketPath   _ -> PIpSocket $ pure hostOrSocketPath++-------------------------------------------------------------------------------+-- Lenses+-- Most this code was generated with microlens-th+-------------------------------------------------------------------------------+-- | Local Lens alias+type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t+-- | Local Lens' alias+type Lens' s a = Lens s s a a++-- | Lens for 'partialEnvVarsInherit'+partialEnvVarsInheritL :: Lens' PartialEnvVars (Last Bool)+partialEnvVarsInheritL f_aj5e (PartialEnvVars x_aj5f x_aj5g)+  = (fmap (\ y_aj5h -> (PartialEnvVars y_aj5h) x_aj5g))+      (f_aj5e x_aj5f)+{-# INLINE partialEnvVarsInheritL #-}++-- | Lens for 'partialEnvVarsSpecific'+partialEnvVarsSpecificL :: Lens' PartialEnvVars (Map String String)+partialEnvVarsSpecificL f_aj5i (PartialEnvVars x_aj5j x_aj5k)+  = (fmap (\ y_aj5l -> (PartialEnvVars x_aj5j) y_aj5l))+      (f_aj5i x_aj5k)+{-# INLINE partialEnvVarsSpecificL #-}++-- | Lens for 'partialProcessConfigCmdLine'+partialProcessConfigCmdLineL ::+  Lens' PartialProcessConfig PartialCommandLineArgs+partialProcessConfigCmdLineL+  f_allv+  (PartialProcessConfig x_allw x_allx x_ally x_allz x_allA)+  = (fmap+       (\ y_allB+          -> ((((PartialProcessConfig x_allw) y_allB) x_ally) x_allz)+               x_allA))+      (f_allv x_allx)+{-# INLINE partialProcessConfigCmdLineL #-}++-- | Lens for 'partialProcessConfigEnvVars'+partialProcessConfigEnvVarsL ::+  Lens' PartialProcessConfig PartialEnvVars+partialProcessConfigEnvVarsL+  f_allC+  (PartialProcessConfig x_allD x_allE x_allF x_allG x_allH)+  = (fmap+       (\ y_allI+          -> ((((PartialProcessConfig y_allI) x_allE) x_allF) x_allG)+               x_allH))+      (f_allC x_allD)+{-# INLINE partialProcessConfigEnvVarsL #-}++-- | Lens for 'partialProcessConfigStdErr'+partialProcessConfigStdErrL ::+  Lens' PartialProcessConfig (Last Handle)+partialProcessConfigStdErrL+  f_allJ+  (PartialProcessConfig x_allK x_allL x_allM x_allN x_allO)+  = (fmap+       (\ y_allP+          -> ((((PartialProcessConfig x_allK) x_allL) x_allM) x_allN)+               y_allP))+      (f_allJ x_allO)++-- | Lens for 'partialProcessConfigStdIn'+{-# INLINE partialProcessConfigStdErrL #-}+partialProcessConfigStdInL ::+  Lens' PartialProcessConfig (Last Handle)+partialProcessConfigStdInL+  f_allQ+  (PartialProcessConfig x_allR x_allS x_allT x_allU x_allV)+  = (fmap+       (\ y_allW+          -> ((((PartialProcessConfig x_allR) x_allS) y_allW) x_allU)+               x_allV))+      (f_allQ x_allT)+{-# INLINE partialProcessConfigStdInL #-}++-- | Lens for 'partialProcessConfigStdOut'+partialProcessConfigStdOutL ::+  Lens' PartialProcessConfig (Last Handle)+partialProcessConfigStdOutL+  f_allX+  (PartialProcessConfig x_allY x_allZ x_alm0 x_alm1 x_alm2)+  = (fmap+       (\ y_alm3+          -> ((((PartialProcessConfig x_allY) x_allZ) x_alm0) y_alm3)+               x_alm2))+      (f_allX x_alm1)+{-# INLINE partialProcessConfigStdOutL #-}++-- | Lens for 'partialPostgresPlanClientConfig'+partialPostgresPlanClientConfigL ::+  Lens' PartialPostgresPlan Client.Options+partialPostgresPlanClientConfigL+  f_am1y+  (PartialPostgresPlan x_am1z x_am1A)+  = (fmap (\ y_am1B -> (PartialPostgresPlan x_am1z) y_am1B))+      (f_am1y x_am1A)+{-# INLINE partialPostgresPlanClientConfigL #-}++-- | Lens for 'partialPostgresPlanProcessConfig'+partialPostgresPlanProcessConfigL ::+  Lens' PartialPostgresPlan PartialProcessConfig+partialPostgresPlanProcessConfigL+  f_am1C+  (PartialPostgresPlan x_am1D x_am1E)+  = (fmap (\ y_am1F -> (PartialPostgresPlan y_am1F) x_am1E))+      (f_am1C x_am1D)+{-# INLINE partialPostgresPlanProcessConfigL #-}++-- | Lens for 'partialPlanConfig'+partialPlanConfigL :: Lens' PartialPlan [String]+partialPlanConfigL+  f_amcw+  (PartialPlan x_amcx x_amcy x_amcz x_amcA x_amcB x_amcC)+  = (fmap+       (\ y_amcD+          -> (((((PartialPlan x_amcx) x_amcy) x_amcz) x_amcA) y_amcD)+               x_amcC))+      (f_amcw x_amcB)+{-# INLINE partialPlanConfigL #-}++-- | Lens for 'partialPlanCreateDb'+partialPlanCreateDbL ::+  Lens' PartialPlan (Maybe PartialProcessConfig)+partialPlanCreateDbL+  f_amcE+  (PartialPlan x_amcF x_amcG x_amcH x_amcI x_amcJ x_amcK)+  = (fmap+       (\ y_amcL+          -> (((((PartialPlan x_amcF) x_amcG) y_amcL) x_amcI) x_amcJ)+               x_amcK))+      (f_amcE x_amcH)+{-# INLINE partialPlanCreateDbL #-}++-- | Lens for 'partialPlanDataDirectory'+partialPlanDataDirectoryL :: Lens' PartialPlan (Last String)+partialPlanDataDirectoryL+  f_amcM+  (PartialPlan x_amcN x_amcO x_amcP x_amcQ x_amcR x_amcS)+  = (fmap+       (\ y_amcT+          -> (((((PartialPlan x_amcN) x_amcO) x_amcP) x_amcQ) x_amcR)+               y_amcT))+      (f_amcM x_amcS)+{-# INLINE partialPlanDataDirectoryL #-}++-- | Lens for 'partialPlanInitDb'+partialPlanInitDbL ::+  Lens' PartialPlan (Maybe PartialProcessConfig)+partialPlanInitDbL+  f_amcU+  (PartialPlan x_amcV x_amcW x_amcX x_amcY x_amcZ x_amd0)+  = (fmap+       (\ y_amd1+          -> (((((PartialPlan x_amcV) y_amd1) x_amcX) x_amcY) x_amcZ)+               x_amd0))+      (f_amcU x_amcW)+{-# INLINE partialPlanInitDbL #-}++-- | Lens for 'partialPlanLogger'+partialPlanLoggerL :: Lens' PartialPlan (Last Logger)+partialPlanLoggerL+  f_amd2+  (PartialPlan x_amd3 x_amd4 x_amd5 x_amd6 x_amd7 x_amd8)+  = (fmap+       (\ y_amd9+          -> (((((PartialPlan y_amd9) x_amd4) x_amd5) x_amd6) x_amd7)+               x_amd8))+      (f_amd2 x_amd3)+{-# INLINE partialPlanLoggerL #-}++-- | Lens for 'partialPlanPostgres'+partialPlanPostgresL :: Lens' PartialPlan PartialPostgresPlan+partialPlanPostgresL+  f_amda+  (PartialPlan x_amdb x_amdc x_amdd x_amde x_amdf x_amdg)+  = (fmap+       (\ y_amdh+          -> (((((PartialPlan x_amdb) x_amdc) x_amdd) y_amdh) x_amdf)+               x_amdg))+      (f_amda x_amde)+{-# INLINE partialPlanPostgresL #-}++-- | Lens for 'resourcesDataDir'+resourcesDataDirL :: Lens' Resources DirectoryType+resourcesDataDirL f_ampd (Resources x_ampe x_ampf x_ampg)+  = (fmap (\ y_amph -> ((Resources x_ampe) x_ampf) y_amph))+      (f_ampd x_ampg)+{-# INLINE resourcesDataDirL #-}++-- | Lens for 'resourcesPlan'+resourcesPlanL :: Lens' Resources Plan+resourcesPlanL f_ampi (Resources x_ampj x_ampk x_ampl)+  = (fmap (\ y_ampm -> ((Resources y_ampm) x_ampk) x_ampl))+      (f_ampi x_ampj)+{-# INLINE resourcesPlanL #-}++-- | Lens for 'resourcesSocket'+resourcesSocketL :: Lens' Resources SocketClass+resourcesSocketL f_ampn (Resources x_ampo x_ampp x_ampq)+  = (fmap (\ y_ampr -> ((Resources x_ampo) y_ampr) x_ampq))+      (f_ampn x_ampp)+{-# INLINE resourcesSocketL #-}++-- | Lens for 'configDataDir'+configDataDirL :: Lens' Config PartialDirectoryType+configDataDirL f_amyD (Config x_amyE x_amyF x_amyG x_amyH)+  = (fmap (\ y_amyI -> (((Config x_amyE) x_amyF) y_amyI) x_amyH))+      (f_amyD x_amyG)+{-# INLINE configDataDirL #-}++-- | Lens for 'configPlan'+configPlanL :: Lens' Config PartialPlan+configPlanL f_amyJ (Config x_amyK x_amyL x_amyM x_amyN)+  = (fmap (\ y_amyO -> (((Config y_amyO) x_amyL) x_amyM) x_amyN))+      (f_amyJ x_amyK)+{-# INLINE configPlanL #-}++-- | Lens for 'configPort'+configPortL :: Lens' Config (Last (Maybe Int))+configPortL f_amyP (Config x_amyQ x_amyR x_amyS x_amyT)+  = (fmap (\ y_amyU -> (((Config x_amyQ) x_amyR) x_amyS) y_amyU))+      (f_amyP x_amyT)+{-# INLINE configPortL #-}++-- | Lens for 'configSocket'+configSocketL :: Lens' Config PartialSocketClass+configSocketL f_amyV (Config x_amyW x_amyX x_amyY x_amyZ)+  = (fmap (\ y_amz0 -> (((Config x_amyW) y_amz0) x_amyY) x_amyZ))+      (f_amyV x_amyX)+{-# INLINE configSocketL #-}++-- | Lens for 'partialCommandLineArgsIndexBased'+partialCommandLineArgsIndexBasedL ::+  Lens' PartialCommandLineArgs (Map Int String)+partialCommandLineArgsIndexBasedL+  f_amNr+  (PartialCommandLineArgs x_amNs x_amNt)+  = (fmap (\ y_amNu -> (PartialCommandLineArgs x_amNs) y_amNu))+      (f_amNr x_amNt)+{-# INLINE partialCommandLineArgsIndexBasedL #-}++-- | Lens for 'partialCommandLineArgsKeyBased'+partialCommandLineArgsKeyBasedL ::+  Lens' PartialCommandLineArgs (Map String (Maybe String))+partialCommandLineArgsKeyBasedL+  f_amNv+  (PartialCommandLineArgs x_amNw x_amNx)+  = (fmap (\ y_amNy -> (PartialCommandLineArgs y_amNy) x_amNx))+      (f_amNv x_amNw)+{-# INLINE partialCommandLineArgsKeyBasedL #-}
tmp-postgres.cabal view
@@ -1,27 +1,7 @@ name:                tmp-postgres-version:             1.7.0.1+version:             1.7.1.0 synopsis: Start and stop a temporary postgres-description:- @tmp-postgres@ provides functions creating a temporary @postgres@ instance.- .- By default it will create a temporary directory for the data,- a random port for listening and a temporary directory for a UNIX- domain socket.- .- Here is an example using the expection safe 'with' function:- .- >  with $ \db -> bracket (connectPostgreSQL (toConnectionString db)) close $ \conn ->- >   execute_ conn "CREATE TABLE foo (id int)"- .- MacOS and Linux are support. Windows is not.- .- Requires PostgreSQL 9.3+- .- WARNING!!- Ubuntu's PostgreSQL installation does not put @initdb@ on the @PATH@. We need to add it manually. The necessary binaries are in the @\/usr\/lib\/postgresql\/VERSION\/bin\/@ directory, and should be added to the @PATH@- .- > echo "export PATH=$PATH:/usr/lib/postgresql/VERSION/bin/" >> /home/ubuntu/.bashrc- .+description: See README.md homepage:            https://github.com/jfischoff/tmp-postgres#readme license:             BSD3 license-file:        LICENSE@@ -30,42 +10,44 @@ copyright:           2017-2019 Jonathan Fischoff category:            Web build-type:          Simple-extra-source-files:  README.md+extra-source-files:  README.md, CHANGELOG.md cabal-version:       >=1.10 tested-with: GHC ==8.6.5  library-  hs-source-dirs:      src+  hs-source-dirs: src   exposed-modules: Database.Postgres.Temp                  , Database.Postgres.Temp.Internal                  , Database.Postgres.Temp.Internal.Core                  , Database.Postgres.Temp.Internal.Partial-  default-extensions: LambdaCase+  default-extensions:+      ApplicativeDo+    , DeriveFunctor+    , DeriveGeneric     , DerivingStrategies     , DerivingVia-    , ScopedTypeVariables-    , RecordWildCards-    , DeriveGeneric+    , GeneralizedNewtypeDeriving+    , LambdaCase     , OverloadedStrings+    , RankNTypes     , RecordWildCards-    , ApplicativeDo-    , DeriveFunctor+    , ScopedTypeVariables+    , TemplateHaskell     , ViewPatterns-    , GeneralizedNewtypeDeriving   build-depends: base >= 4.6 && < 5-               , temporary-               , process >= 1.2.0.0-               , unix-               , directory-               , bytestring-               , postgresql-simple-               , postgres-options >= 0.2.0.0-               , port-utils+               , ansi-wl-pprint                , async+               , bytestring+               , containers+               , directory                , generic-monoid+               , port-utils+               , postgres-options >= 0.2.0.0+               , postgresql-simple+               , process >= 1.2.0.0+               , temporary                , transformers-               , containers-               , ansi-wl-pprint+               , unix   ghc-options: -Wall   default-language:    Haskell2010 @@ -76,35 +58,30 @@   main-is:             Spec.hs   build-depends:       base                      , containers-                     , postgresql-libpq-                     , tmp-postgres-                     , hspec-                     , temporary                      , directory-                     , process-                     , postgresql-simple-                     , bytestring+                     , hspec                      , mtl-                     , unix-                     , temporary-                     , either-                     , transformers-                     , postgres-options                      , port-utils+                     , postgres-options+                     , postgresql-simple+                     , process+                     , temporary+                     , tmp-postgres+                     , unix    ghc-options:        -Wall -threaded -rtsopts -with-rtsopts=-N   default-language:    Haskell2010-  default-extensions: LambdaCase+  default-extensions:+      DeriveDataTypeable+    , DeriveGeneric     , DerivingStrategies     , DerivingVia-    , ScopedTypeVariables-    , RecordWildCards-    , DeriveGeneric+    , LambdaCase     , OverloadedStrings-    , RecordWildCards-    , DeriveDataTypeable     , QuasiQuotes     , RankNTypes+    , RecordWildCards+    , ScopedTypeVariables   source-repository head