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 | |
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
-rw-r--r-- | src/Squeal/PostgreSQL/Hspec.hs | 23 | ||||
-rw-r--r-- | stack.yaml | 12 |
2 files changed, 16 insertions, 19 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) |
@@ -18,7 +18,7 @@ | |||
18 | # | 18 | # |
19 | # resolver: ./custom-snapshot.yaml | 19 | # resolver: ./custom-snapshot.yaml |
20 | # resolver: https://example.com/snapshots/2018-01-01.yaml | 20 | # resolver: https://example.com/snapshots/2018-01-01.yaml |
21 | resolver: lts-12.20 | 21 | resolver: lts-13.18 |
22 | 22 | ||
23 | # User packages to be built. | 23 | # User packages to be built. |
24 | # Various formats can be used as shown in the example below. | 24 | # Various formats can be used as shown in the example below. |
@@ -40,9 +40,13 @@ packages: | |||
40 | # using the same syntax as the packages field. | 40 | # using the same syntax as the packages field. |
41 | # (e.g., acme-missiles-0.3) | 41 | # (e.g., acme-missiles-0.3) |
42 | extra-deps: | 42 | extra-deps: |
43 | - squeal-postgresql-0.4.0.0 | 43 | - git: https://github.com/morphismtech/squeal |
44 | - records-sop-0.1.0.2 | 44 | commit: cd3de98230645ba763183fcae3f7c38faf119c89 |
45 | - tmp-postgres-0.1.1.0 | 45 | subdirs: |
46 | - squeal-postgresql | ||
47 | - unliftio-pool-0.2.1.0@sha256:4de658feb1b10051c5af024c20cd7baa369c777716c54a7b3e2888a73286aecf | ||
48 | - records-sop-0.1.0.2 | ||
49 | - tmp-postgres-0.1.1.0 | ||
46 | 50 | ||
47 | # Override default flag values for local packages and extra-deps | 51 | # Override default flag values for local packages and extra-deps |
48 | # flags: {} | 52 | # flags: {} |