Skip to content

Commit c1f6c19

Browse files
committed
Added postgres-embedded for tests
1 parent 6361568 commit c1f6c19

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cache:
66
directories:
77
- $HOME/.cabsnap
88
- $HOME/.cabal/packages
9+
- $HOME/.postgres-embedded
910

1011
before_cache:
1112
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
@@ -15,16 +16,16 @@ matrix:
1516
include:
1617
- env: CABALVER=1.16 GHCVER=7.6.3
1718
compiler: ": #GHC 7.6.3"
18-
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}, postgresql: "9.3"}
19+
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
1920
- env: CABALVER=1.18 GHCVER=7.8.4
2021
compiler: ": #GHC 7.8.4"
21-
addons: { apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}, postgresql: "9.3"}
22+
addons: { apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
2223
- env: CABALVER=1.22 GHCVER=7.10.2
2324
compiler: ": #GHC 7.10.2"
24-
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}, postgresql: "9.3"}
25+
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}}
2526
- env: CABALVER=1.24 GHCVER=8.0.1
2627
compiler: ": #GHC 8.0.1"
27-
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}, postgresql: "9.3"}
28+
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
2829

2930
before_install:
3031
- unset CC

postgresql-simple.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ test-suite test
129129
, text
130130
, time
131131
, vector
132+
, postgres-embedded >= 0.1.7 && <0.2
132133

133134
if !impl(ghc >= 7.6)
134135
build-depends:

test/Main.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{-# LANGUAGE DoAndIfThenElse #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
66
import Common
7+
import Database.PostgreSQL.Embedded
78
import Database.PostgreSQL.Simple.FromField (FromField)
89
import Database.PostgreSQL.Simple.Types(Query(..),Values(..))
910
import Database.PostgreSQL.Simple.HStore
@@ -469,7 +470,7 @@ isSyntaxError SqlError{..} = sqlState == "42601"
469470
-- Note that some tests, such as Notify, use multiple connections, and assume
470471
-- that 'testConnect' connects to the same database every time it is called.
471472
testConnect :: IO Connection
472-
testConnect = connectPostgreSQL ""
473+
testConnect = connectPostgreSQL "host=127.0.0.1 user=postgres dbname=postgres port=46782"
473474

474475
withTestEnv :: (TestEnv -> IO a) -> IO a
475476
withTestEnv cb =
@@ -482,4 +483,10 @@ withTestEnv cb =
482483
withConn = bracket testConnect close
483484

484485
main :: IO ()
485-
main = withTestEnv $ defaultMain . tests
486+
main = do
487+
let sConfig = StartupConfig True (Version "9.6.5-1")
488+
let dConfig = DBConfig 46782 "postgres"
489+
rc <- startPostgres sConfig dConfig
490+
withTestEnv $ defaultMain . tests
491+
stopPostgres rc
492+
return ()

0 commit comments

Comments
 (0)