WIP: load fixture before all tests
This commit is contained in:
+6
-5
@@ -7,21 +7,22 @@ import Database.HDBC.PostgreSQL
|
|||||||
|
|
||||||
loadFixture :: String -> IO ()
|
loadFixture :: String -> IO ()
|
||||||
loadFixture name = do
|
loadFixture name = do
|
||||||
sql <- readFile $ "test/fixtures/" ++ name ++ ".sql"
|
|
||||||
conn <- connectPostgreSQL "postgres://postgres:@localhost:5432/dbapi_test"
|
conn <- connectPostgreSQL "postgres://postgres:@localhost:5432/dbapi_test"
|
||||||
|
sql <- readFile $ "test/fixtures/" ++ name ++ ".sql"
|
||||||
|
runRaw conn "drop schema if exists public cascade"
|
||||||
|
runRaw conn "create schema public"
|
||||||
runRaw conn sql
|
runRaw conn sql
|
||||||
commit conn
|
commit conn
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = hspec spec
|
||||||
hspec spec
|
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = beforeAll (loadFixture "schema") $ do
|
spec = beforeAll (loadFixture "schema") $ do
|
||||||
describe "insert" $
|
describe "insert" $
|
||||||
it "can insert into an empty table" $
|
it "can insert into an empty table" $ \_ ->
|
||||||
head [23 ..] `shouldBe` (23 :: Int)
|
head [23 ..] `shouldBe` (23 :: Int)
|
||||||
|
|
||||||
describe "insert again" $
|
describe "insert again" $
|
||||||
it "is true" $
|
it "is true" $ \_ ->
|
||||||
True `shouldBe` True
|
True `shouldBe` True
|
||||||
|
|||||||
Reference in New Issue
Block a user