aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Squeal
diff options
context:
space:
mode:
authorRaveline <eraveline@gmail.com>2019-05-03 10:25:18 +0200
committerRaveline <eraveline@gmail.com>2019-05-03 10:25:18 +0200
commitd8e546eb86a18c4e61c2e2f0844d5c29dd358d38 (patch)
tree6694853fc7705a67b4f8b9f8ac92c4a53d026a94 /src/Squeal
parent8c738ffcd5ba7ad6c38303857cd351d01d4bba5f (diff)
downloadsqueal-hspec-d8e546eb86a18c4e61c2e2f0844d5c29dd358d38.tar.gz
squeal-hspec-d8e546eb86a18c4e61c2e2f0844d5c29dd358d38.tar.zst
squeal-hspec-d8e546eb86a18c4e61c2e2f0844d5c29dd358d38.zip
Bump squeal version
Diffstat (limited to 'src/Squeal')
-rw-r--r--src/Squeal/PostgreSQL/Hspec.hs23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/Squeal/PostgreSQL/Hspec.hs b/src/Squeal/PostgreSQL/Hspec.hs
index 44011b7..3cd886b 100644
--- a/src/Squeal/PostgreSQL/Hspec.hs
+++ b/src/Squeal/PostgreSQL/Hspec.hs
@@ -10,7 +10,6 @@ The libary also provides a few other functions for more fine grained control ove
10-} 10-}
11{-# LANGUAGE DataKinds #-} 11{-# LANGUAGE DataKinds #-}
12{-# LANGUAGE FlexibleContexts #-} 12{-# LANGUAGE FlexibleContexts #-}
13{-# LANGUAGE KindSignatures #-}
14{-# LANGUAGE MonoLocalBinds #-} 13{-# LANGUAGE MonoLocalBinds #-}
15{-# LANGUAGE RankNTypes #-} 14{-# LANGUAGE RankNTypes #-}
16{-# LANGUAGE RecordWildCards #-} 15{-# LANGUAGE RecordWildCards #-}
@@ -21,13 +20,11 @@ where
21 20
22import Control.Exception 21import Control.Exception
23import Control.Monad 22import Control.Monad
24import Control.Monad.Base (liftBase) 23import Control.Monad.Base (liftBase)
25import Control.Monad.Trans.Control (MonadBaseControl) 24import qualified Data.ByteString.Char8 as BSC
26import qualified Data.ByteString.Char8 as BSC 25import qualified Database.Postgres.Temp as Temp
27import qualified Database.Postgres.Temp as Temp 26import Generics.SOP (K)
28import Generics.SOP (K)
29import Squeal.PostgreSQL 27import Squeal.PostgreSQL
30import Squeal.PostgreSQL.Migration
31import Squeal.PostgreSQL.Pool 28import Squeal.PostgreSQL.Pool
32import Test.Hspec 29import Test.Hspec
33 30
@@ -38,17 +35,13 @@ data TestDB a = TestDB
38 -- ^ Pool of 50 connections to the temporary @postgres@ 35 -- ^ Pool of 50 connections to the temporary @postgres@
39 } 36 }
40 37
41type Migrations schema m a = (MonadBaseControl IO m) =>
42 PQ (("schema_migrations" ::: Table MigrationsTable) ': '[])
43 (("schema_migrations" ::: Table MigrationsTable) ': schema) m a
44
45type Fixtures schema = (Pool (K Connection schema) -> IO ()) 38type Fixtures schema = (Pool (K Connection schema) -> IO ())
46type Actions schema a = PoolPQ schema IO a 39type Actions schema a = PoolPQ schema IO a
47type SquealContext (schema :: SchemaType) = TestDB (K Connection schema) 40type SquealContext schema = TestDB (K Connection schema)
48 41
49-- | Start a temporary @postgres@ process and create a pool of connections to it 42-- | Start a temporary @postgres@ process and create a pool of connections to it
50setupDB 43setupDB
51 :: Migrations schema IO a 44 :: AlignedList (Migration (Terminally PQ IO)) schema0 schema
52 -> Fixtures schema 45 -> Fixtures schema
53 -> IO (SquealContext schema) 46 -> IO (SquealContext schema)
54setupDB migration fixtures = do 47setupDB migration fixtures = do
@@ -63,7 +56,7 @@ setupDB migration fixtures = do
63 singleStripe 56 singleStripe
64 keepConnectionForOneHour 57 keepConnectionForOneHour
65 poolSizeOfFifty 58 poolSizeOfFifty
66 withConnection connectionString migration 59 withConnection connectionString (migrateUp migration)
67 fixtures pool 60 fixtures pool
68 pure TestDB {..} 61 pure TestDB {..}
69 62
@@ -105,7 +98,7 @@ itDB msg action = it msg $ void . withDB action
105-- 98--
106-- hook for stopping a db. 99-- hook for stopping a db.
107describeDB 100describeDB
108 :: Migrations schema IO a 101 :: AlignedList (Migration (Terminally PQ IO)) schema0 schema
109 -> Fixtures schema 102 -> Fixtures schema
110 -> String 103 -> String
111 -> SpecWith (SquealContext schema) 104 -> SpecWith (SquealContext schema)