Remove connection pooling in test
This commit is contained in:
+4
-3
@@ -3,10 +3,11 @@ module Main where
|
||||
import Test.Hspec
|
||||
import SpecHelper
|
||||
|
||||
import Data.Pool
|
||||
import qualified Hasql.Session as H
|
||||
import qualified Hasql.Connection as H
|
||||
|
||||
import PostgREST.DbStructure (getDbStructure)
|
||||
import Data.String.Conversions (cs)
|
||||
|
||||
import qualified Feature.AuthSpec
|
||||
import qualified Feature.CorsSpec
|
||||
@@ -21,14 +22,14 @@ main :: IO ()
|
||||
main = do
|
||||
setupDb
|
||||
|
||||
pool <- testPool
|
||||
withResource pool $ \case
|
||||
H.acquire (cs dbString) >>= \case
|
||||
Left err -> error $ show err
|
||||
Right c -> do
|
||||
dbOrErr <- H.run (getDbStructure "test") c
|
||||
-- Not using hspec-discover because we want to precompute
|
||||
-- the db structure and pass it to specs for speed
|
||||
either (error.show) (hspec . specs c) dbOrErr
|
||||
H.release c
|
||||
|
||||
where
|
||||
specs conn dbStructure = do
|
||||
|
||||
@@ -84,7 +84,3 @@ authHeaderBasic u p =
|
||||
authHeaderJWT :: String -> Header
|
||||
authHeaderJWT token =
|
||||
(hAuthorization, cs $ "Bearer " ++ token)
|
||||
|
||||
testPool :: IO (Pool (Either H.ConnectionError H.Connection))
|
||||
testPool = createPool (H.acquire . cs $ dbString)
|
||||
(either (const $ return ()) H.release) 1 1 1
|
||||
|
||||
Reference in New Issue
Block a user