Last active
August 29, 2015 14:04
-
-
Save lubomir/6666ab670240a25cd62d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Database.Persist as P | |
main :: IO () | |
main = do | |
conf <- Yesod.Default.Config.loadConfig $ (configSettings Testing) | |
{ csParseExtra = parseExtra | |
} | |
dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf) | |
P.loadConfig >>= | |
P.applyEnv | |
pool <- P.createPoolConfig dbconf | |
runNoLoggingT $ P.runPool dbconf (rawExecute "SET client_min_messages TO WARNING" []) pool | |
foundation <- makeFoundation conf >>= replaceLogger | |
hspec $ do | |
before (removeDb dbconf pool) $ | |
yesodSpec foundation $ do | |
undefined | |
removeDb :: Settings.PersistConf -> ConnectionPool -> IO () | |
removeDb dbconf p = runNoLoggingT $ P.runPool dbconf reset p | |
where | |
reset = do | |
rawExecute "DROP SCHEMA public CASCADE" [] | |
rawExecute "CREATE SCHEMA public" [] | |
runMigrationSilent migrateAll >> return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment