Temporarily use psql to load schemas

This commit is contained in:
Joe Nelson
2014-12-06 17:42:20 -08:00
parent dba17b895e
commit 21b0b02c03
2 changed files with 8 additions and 11 deletions
+1
View File
@@ -83,3 +83,4 @@ Test-Suite spec
, blaze-builder
, vector
, mtl
, process
+7 -11
View File
@@ -2,28 +2,24 @@
module Main where
import qualified Hasql as H
import qualified Hasql.Backend as H
import qualified Hasql.Postgres as H
import qualified Data.ByteString.Char8 as BS
import System.Process
import Test.Hspec
import SpecHelper
import Spec
main :: IO ()
main = do
roles <- loadFixture "roles"
schema <- loadFixture "schema"
H.session pgSettings testSettings $
H.tx Nothing $ do
H.unit [H.q| drop schema if exists "1" cascade |]
H.unit [H.q| drop schema if exists private cascade |]
H.unit [H.q| drop schema if exists dbapi cascade |]
H.unit roles
H.unit schema
loadFixture "roles"
loadFixture "schema"
hspec spec
loadFixture :: FilePath -> IO(H.Statement H.Postgres)
loadFixture name = do
query <- BS.readFile $ "test/fixtures/" ++ name ++ ".sql"
return (query, [], False)
loadFixture :: FilePath -> IO()
loadFixture name =
callProcess "psql" ["-U", "postgres", "-d", "dbapi_test", "-a", "-f", "test/fixtures/" ++ name ++ ".sql"]