Feature tests pass, unit test does not
This commit is contained in:
+6
-12
@@ -10,8 +10,6 @@ import Control.Exception.Base (bracket)
|
||||
|
||||
import Dbapi (app, AppConfig(..))
|
||||
|
||||
import Debug.Trace
|
||||
|
||||
cfg :: AppConfig
|
||||
cfg = AppConfig "postgres://postgres:@localhost:5432/dbapi_test" 9000
|
||||
|
||||
@@ -23,21 +21,17 @@ withDatabaseConnection = bracket openConnection disconnect
|
||||
|
||||
loadFixture :: String -> Connection -> IO ()
|
||||
loadFixture name conn = do
|
||||
runRaw conn "begin;"
|
||||
sql <- readFile $ "test/fixtures/" ++ name ++ ".sql"
|
||||
runRaw conn sql
|
||||
|
||||
rollbackFixture :: Connection -> IO ()
|
||||
rollbackFixture = flip runRaw "rollback;"
|
||||
|
||||
dbWithSchema :: ActionWith Connection -> IO ()
|
||||
dbWithSchema action = withDatabaseConnection $ \c -> do
|
||||
trace "Load fixture" loadFixture "schema" c
|
||||
trace "act" action (c)
|
||||
trace "rollback" rollbackFixture c
|
||||
runRaw c "begin;"
|
||||
action c
|
||||
rollback c
|
||||
|
||||
appWithFixture :: ActionWith Application -> IO ()
|
||||
appWithFixture action = withDatabaseConnection $ \c -> do
|
||||
loadFixture "schema" c
|
||||
action (app cfg)
|
||||
rollbackFixture c
|
||||
runRaw c "begin;"
|
||||
action $ app c
|
||||
rollback c
|
||||
|
||||
Reference in New Issue
Block a user