diff options
author | A.D <Raveline@users.noreply.github.com> | 2019-05-03 10:40:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 10:40:07 +0200 |
commit | fc6d19e370eded2d5c819d1ef186e26ecd9419f2 (patch) | |
tree | 6694853fc7705a67b4f8b9f8ac92c4a53d026a94 /src/Squeal | |
parent | 8c738ffcd5ba7ad6c38303857cd351d01d4bba5f (diff) | |
parent | d8e546eb86a18c4e61c2e2f0844d5c29dd358d38 (diff) | |
download | squeal-hspec-fc6d19e370eded2d5c819d1ef186e26ecd9419f2.tar.gz squeal-hspec-fc6d19e370eded2d5c819d1ef186e26ecd9419f2.tar.zst squeal-hspec-fc6d19e370eded2d5c819d1ef186e26ecd9419f2.zip |
Merge pull request #1 from Raveline/bump-squeal
Follow latest Squeal commit
Diffstat (limited to 'src/Squeal')
-rw-r--r-- | src/Squeal/PostgreSQL/Hspec.hs | 23 |
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 | ||
22 | import Control.Exception | 21 | import Control.Exception |
23 | import Control.Monad | 22 | import Control.Monad |
24 | import Control.Monad.Base (liftBase) | 23 | import Control.Monad.Base (liftBase) |
25 | import Control.Monad.Trans.Control (MonadBaseControl) | 24 | import qualified Data.ByteString.Char8 as BSC |
26 | import qualified Data.ByteString.Char8 as BSC | 25 | import qualified Database.Postgres.Temp as Temp |
27 | import qualified Database.Postgres.Temp as Temp | 26 | import Generics.SOP (K) |
28 | import Generics.SOP (K) | ||
29 | import Squeal.PostgreSQL | 27 | import Squeal.PostgreSQL |
30 | import Squeal.PostgreSQL.Migration | ||
31 | import Squeal.PostgreSQL.Pool | 28 | import Squeal.PostgreSQL.Pool |
32 | import Test.Hspec | 29 | import 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 | ||
41 | type Migrations schema m a = (MonadBaseControl IO m) => | ||
42 | PQ (("schema_migrations" ::: Table MigrationsTable) ': '[]) | ||
43 | (("schema_migrations" ::: Table MigrationsTable) ': schema) m a | ||
44 | |||
45 | type Fixtures schema = (Pool (K Connection schema) -> IO ()) | 38 | type Fixtures schema = (Pool (K Connection schema) -> IO ()) |
46 | type Actions schema a = PoolPQ schema IO a | 39 | type Actions schema a = PoolPQ schema IO a |
47 | type SquealContext (schema :: SchemaType) = TestDB (K Connection schema) | 40 | type 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 |
50 | setupDB | 43 | setupDB |
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) |
54 | setupDB migration fixtures = do | 47 | setupDB 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. |
107 | describeDB | 100 | describeDB |
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) |