From f0d80fc8504cc2219f10168adcb0c5b4d5d1932c Mon Sep 17 00:00:00 2001 From: Ilya Murzinov Date: Sun, 15 Oct 2017 20:32:41 +0300 Subject: [PATCH] Added postgres-embedded for tests --- .travis.yml | 10 ++++------ postgresql-simple.cabal | 1 + test/Main.hs | 11 +++++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 48e92e12..dc6d2d6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ cache: directories: - $HOME/.cabsnap - $HOME/.cabal/packages + - $HOME/.postgres-embedded before_cache: - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log @@ -13,18 +14,15 @@ before_cache: matrix: include: - - env: CABALVER=1.16 GHCVER=7.6.3 - compiler: ": #GHC 7.6.3" - addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}, postgresql: "9.3"} - env: CABALVER=1.18 GHCVER=7.8.4 compiler: ": #GHC 7.8.4" - addons: { apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}, postgresql: "9.3"} + addons: { apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}} - env: CABALVER=1.22 GHCVER=7.10.2 compiler: ": #GHC 7.10.2" - addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}, postgresql: "9.3"} + addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}} - env: CABALVER=1.24 GHCVER=8.0.1 compiler: ": #GHC 8.0.1" - addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}, postgresql: "9.3"} + addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}} before_install: - unset CC diff --git a/postgresql-simple.cabal b/postgresql-simple.cabal index 74169ec7..a9991bdf 100644 --- a/postgresql-simple.cabal +++ b/postgresql-simple.cabal @@ -129,6 +129,7 @@ test-suite test , text , time , vector + , postgres-embedded >= 0.1.7 && <0.2 if !impl(ghc >= 7.6) build-depends: diff --git a/test/Main.hs b/test/Main.hs index d71a9d0a..4f78693d 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -4,6 +4,7 @@ {-# LANGUAGE DoAndIfThenElse #-} {-# LANGUAGE ScopedTypeVariables #-} import Common +import Database.PostgreSQL.Embedded import Database.PostgreSQL.Simple.FromField (FromField) import Database.PostgreSQL.Simple.Types(Query(..),Values(..)) import Database.PostgreSQL.Simple.HStore @@ -469,7 +470,7 @@ isSyntaxError SqlError{..} = sqlState == "42601" -- Note that some tests, such as Notify, use multiple connections, and assume -- that 'testConnect' connects to the same database every time it is called. testConnect :: IO Connection -testConnect = connectPostgreSQL "" +testConnect = connectPostgreSQL "host=127.0.0.1 user=postgres dbname=postgres port=46782" withTestEnv :: (TestEnv -> IO a) -> IO a withTestEnv cb = @@ -482,4 +483,10 @@ withTestEnv cb = withConn = bracket testConnect close main :: IO () -main = withTestEnv $ defaultMain . tests +main = do + let sConfig = StartupConfig True (Version "9.6.5-1") + let dConfig = DBConfig 46782 "postgres" + rc <- startPostgres sConfig dConfig + withTestEnv $ defaultMain . tests + stopPostgres rc + return ()