packages feed

postgres-embedded 0.1.7 → 0.1.8

raw patch · 5 files changed

+35/−31 lines, 5 filesdep +processdep −shell-conduitPVP ok

version bump matches the API change (PVP)

Dependencies added: process

Dependencies removed: shell-conduit

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+# Changes++## 0.1.8++Removed shell-conduit dependency as it causes lots of problems+ ## 0.1.7  Unstable version for testing
postgres-embedded.cabal view
@@ -1,7 +1,8 @@ name:                postgres-embedded-version:             0.1.7-description:         Library for easily running embedded PostgreSQL server for tests-synopsis:            Library for easily running embedded PostgreSQL server for tests+version:             0.1.8+description:         Library for easily running embedded PostgreSQL server for tests. +                     It downloads, runs, checks and stops PostgreSQL Database instance for you.+synopsis:            Library for easily running embedded PostgreSQL server for tests. homepage:            https://github.com/ilya-murzinov/postgres-embedded bug-reports:         https://github.com/ilya-murzinov/postgres-embedded/issues license:             MIT@@ -13,7 +14,7 @@ build-type:          Simple extra-doc-files:     README.md                      CHANGELOG.md-cabal-version:       >=1.18+cabal-version:       >= 1.18 tested-with:         GHC==8.2.1, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4  source-repository head@@ -29,8 +30,8 @@   build-depends:       base >= 4 && < 5                      , directory                      , filepath-                     , shell-conduit                      , network+                     , process   ghc-options:         -Wall   default-language:    Haskell2010 @@ -43,6 +44,6 @@                      , filepath                      , postgres-embedded                      , postgresql-simple-                     , shell-conduit+                     , process   ghc-options:         -threaded -rtsopts -with-rtsopts=-N   default-language:    Haskell2010
src/Database/PostgreSQL/Embedded/Download.hs view
@@ -2,9 +2,10 @@     ( downloadPostgres     ) where -import           Data.Conduit.Shell                 (cd, run, tar, unzip', wget)+import           System.Process                     (rawSystem) import           Data.Monoid                        ((<>))-import           System.Directory                   (createDirectoryIfMissing,+import           System.Directory                   (setCurrentDirectory,+                                                     createDirectoryIfMissing,                                                      doesDirectoryExist,                                                      getHomeDirectory) import           System.FilePath.Posix              ((</>))@@ -27,19 +28,15 @@     exists <- doesDirectoryExist dist     case exists of         True -> return dist-        False -> run $ do-            cd workdir-+        False -> do+            setCurrentDirectory workdir             let (aType, suffix) = binaries os_--            wget "-O" tmp $ base_download_url <> v <> suffix--            case aType of-                Zip -> unzip' "-q" tmp-                Tar -> tar "-xzf" tmp-+            _ <- rawSystem "wget" ["-O", tmp, base_download_url <> v <> suffix]+            _ <- case aType of+                Zip -> rawSystem "unzip" ["-q", tmp]+                Tar -> rawSystem "tar" ["-xzf", tmp]             return dist-+                         where                 binaries :: Os -> (ArchiveType, String)                 binaries OSX   = (Zip, "-osx-binaries.zip")
src/Database/PostgreSQL/Embedded/Postgres.hs view
@@ -5,7 +5,7 @@     ) where  import           Control.Exception                     (SomeException, try)-import           Data.Conduit.Shell                    (rm, run, shell)+import           System.Process                        (system) import           Data.List                             (isInfixOf) import           Data.Monoid                           ((<>)) import           System.Directory                      (doesDirectoryExist)@@ -26,14 +26,14 @@     e <- downloadPostgres getOS version_     let d = e </> "data"     exists <- doesDirectoryExist d-    if exists && not сlean then do+    _ <- if exists && not сlean then do         putStrLn $ "Directory " <> d <> " must not exist"         exitFailure-    else run $ rm "-rf" d+    else system $ "rm" <> " -rf " <> d -    run $ do-        shell $ e </> "bin" </> "initdb" <> " -A trust -U " <> u <> " -D " <> d <> " -E UTF-8"-        shell $ e </> "bin" </> "pg_ctl" <> " -D " <> d <> " -o \"-F -p " <>+    _ <- do+        _ <- system $ e </> "bin" </> "initdb" <> " -A trust -U " <> u <> " -D " <> d <> " -E UTF-8"+        system $ e </> "bin" </> "pg_ctl" <> " -w " <> " -D " <> d <> " -o \"-F -p " <>             show p <> "\"" <> " -l " <> (e </> "log") <> " start"      let r = RuntimeConfig e d@@ -52,16 +52,16 @@ Doesn't remove data directory. -} stopPostgres :: RuntimeConfig -> IO ()-stopPostgres (RuntimeConfig e d) = run $-        shell $ e </> "bin" </> "pg_ctl" <> " -D " <> d <> " stop" <>-                " -m fast -t 5 -w"+stopPostgres (RuntimeConfig e d) = do+        _ <- system $ e </> "bin" </> "pg_ctl" <> " -D " <> d <> " stop" <> " -m fast -t 5 -w"+        return ()  checkPostgresStarted :: RuntimeConfig -> DBConfig -> IO () checkPostgresStarted (RuntimeConfig e _) (DBConfig p _) = checkPostgresStarted_ 10 >>= \_ -> return ()     where         checkPostgresStarted_ :: Int -> IO Bool         checkPostgresStarted_ n = do-            let check = run $ shell (e </> "bin" </> "pg_isready" <> " -p " <> show p <> " -h localhost") >>= \_ -> return True+            let check = system (e </> "bin" </> "pg_isready" <> " -p " <> show p <> " -h localhost") >>= \_ -> return True              res <- try check :: IO (Either SomeException Bool)             let retry = if n > 0 then checkPostgresStarted_ (n - 1)
test/Spec.hs view
@@ -1,10 +1,10 @@ import           Data.ByteString.Char8        (pack)-import           Data.Conduit.Shell           (rm, run) import           Data.Monoid                  ((<>)) import           Data.String                  (fromString) import           Database.PostgreSQL.Simple   (Only (..), connectPostgreSQL,                                                query_) import           System.FilePath.Posix        ((</>))+import           System.Process               (system)  import           Database.PostgreSQL.Embedded @@ -13,7 +13,7 @@     let sConfig = StartupConfig True (Version "9.6.5-1")     let dConfig = DBConfig 46782 "postgres" -    run $ rm "-rf" $ "~/.postgres-embedded/" </> "9.6.5-1"+    system $ "rm" <> " -rf " <> ("~/.postgres-embedded/" </> "9.6.5-1")      -- Start Postgres downloading distribution     rc <- startPostgres sConfig dConfig