Skip to content

Instantly share code, notes, and snippets.

@lubomir
Last active August 29, 2015 14:04
Show Gist options
  • Save lubomir/6666ab670240a25cd62d to your computer and use it in GitHub Desktop.
Save lubomir/6666ab670240a25cd62d to your computer and use it in GitHub Desktop.
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