From 21b0b02c03b7572fe43ef44200cf4320f26b506d Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 20 Nov 2014 23:13:48 -0800 Subject: [PATCH] Temporarily use psql to load schemas --- dbapi.cabal | 1 + test/Main.hs | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dbapi.cabal b/dbapi.cabal index 9250400fa..a1d446709 100644 --- a/dbapi.cabal +++ b/dbapi.cabal @@ -83,3 +83,4 @@ Test-Suite spec , blaze-builder , vector , mtl + , process diff --git a/test/Main.hs b/test/Main.hs index 115171702..934732564 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -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"]