Scaffolding update

This commit is contained in:
Michael Snoyman 2013-02-19 08:00:25 +02:00
parent a0dd09c2e1
commit 729221bf2f
5 changed files with 168 additions and 36 deletions

View File

@ -26,9 +26,11 @@ import Yesod.Auth
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Default.Main import Yesod.Default.Main
import Yesod.Default.Handlers import Yesod.Default.Handlers
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev) import Network.Wai.Middleware.RequestLogger
import qualified Database.Persist.Store import qualified Database.Persist.Store
import Network.HTTP.Conduit (newManager, def) import Network.HTTP.Conduit (newManager, def)
import System.IO (stdout)
import System.Log.FastLogger (mkLogger)
-- Import all relevant handler modules here. -- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file! -- Don't forget to add new modules to your cabal file!
@ -46,12 +48,22 @@ mkYesodDispatch "App" resourcesApp
makeApplication :: AppConfig DefaultEnv Extra -> IO Application makeApplication :: AppConfig DefaultEnv Extra -> IO Application
makeApplication conf = do makeApplication conf = do
foundation <- makeFoundation conf foundation <- makeFoundation conf
-- Initialize the logging middleware
logWare <- mkRequestLogger def
{ outputFormat =
if development
then Detailed True
else Apache FromSocket
, destination = Logger $ appLogger foundation
}
-- Create the WAI application and apply middlewares
app <- toWaiAppPlain foundation app <- toWaiAppPlain foundation
return $ logWare app return $ logWare app
where
logWare = if development then logStdoutDev
else logStdout
-- | Loads up any necessary settings, creates your foundation datatype, and
-- performs some initialization.
makeFoundation :: AppConfig DefaultEnv Extra -> IO App makeFoundation :: AppConfig DefaultEnv Extra -> IO App
makeFoundation conf = do makeFoundation conf = do
manager <- newManager def manager <- newManager def
@ -60,7 +72,10 @@ makeFoundation conf = do
Database.Persist.Store.loadConfig >>= Database.Persist.Store.loadConfig >>=
Database.Persist.Store.applyEnv Database.Persist.Store.applyEnv
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig) p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
return $ App conf s p manager dbconf logger <- mkLogger True stdout
let foundation = App conf s p manager dbconf logger
return foundation
-- for yesod devel -- for yesod devel
getApplicationDev :: IO (Int, Application) getApplicationDev :: IO (Int, Application)
@ -93,6 +108,7 @@ import Model
import Text.Jasmine (minifym) import Text.Jasmine (minifym)
import Web.ClientSession (getKey) import Web.ClientSession (getKey)
import Text.Hamlet (hamletFile) import Text.Hamlet (hamletFile)
import System.Log.FastLogger (Logger)
-- | The site argument for your application. This can be a good place to -- | The site argument for your application. This can be a good place to
-- keep settings and values requiring initialization before your application -- keep settings and values requiring initialization before your application
@ -104,6 +120,7 @@ data App = App
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool. , connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
, httpManager :: Manager , httpManager :: Manager
, persistConfig :: Settings.PersistConfig , persistConfig :: Settings.PersistConfig
, appLogger :: Logger
} }
-- Set up i18n messages. See the message folder. -- Set up i18n messages. See the message folder.
@ -399,6 +416,9 @@ library
, warp >= 1.3 && < 1.4 , warp >= 1.3 && < 1.4
, data-default , data-default
, aeson , aeson
, conduit >= 1.0
, monad-logger >= 0.3
, fast-logger >= 0.3
executable PROJECTNAME executable PROJECTNAME
if flag(library-only) if flag(library-only)
@ -426,6 +446,7 @@ test-suite test
, persistent , persistent
, persistent-mongoDB , persistent-mongoDB
, resourcet , resourcet
, monad-logger
{-# START_FILE Settings.hs #-} {-# START_FILE Settings.hs #-}
-- | Settings are centralized, as much as possible, into this file. This -- | Settings are centralized, as much as possible, into this file. This
@ -5773,15 +5794,18 @@ import Yesod.Test
import Database.Persist hiding (get) import Database.Persist hiding (get)
import Database.Persist.MongoDB hiding (master) import Database.Persist.MongoDB hiding (master)
import Control.Monad.Trans.Resource (ResourceT, runResourceT) import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Model import Model
type Specs = SpecsConn Connection type Specs = SpecsConn Connection
runDB :: Action (ResourceT IO) a -> OneSpec Connection a runDB :: Action (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
runDB = runDBRunner poolRunner runDB = runDBRunner poolRunner
where where
poolRunner query pool = runResourceT $ runMongoDBPoolDef query pool poolRunner query pool = runResourceT
$ runNoLoggingT
$ runMongoDBPoolDef query pool
{-# START_FILE tests/main.hs #-} {-# START_FILE tests/main.hs #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}

View File

@ -26,10 +26,13 @@ import Yesod.Auth
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Default.Main import Yesod.Default.Main
import Yesod.Default.Handlers import Yesod.Default.Handlers
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev) import Network.Wai.Middleware.RequestLogger
import qualified Database.Persist.Store import qualified Database.Persist.Store
import Database.Persist.GenericSql (runMigration) import Database.Persist.GenericSql (runMigration)
import Network.HTTP.Conduit (newManager, def) import Network.HTTP.Conduit (newManager, def)
import Control.Monad.Logger (runLoggingT)
import System.IO (stdout)
import System.Log.FastLogger (mkLogger)
-- Import all relevant handler modules here. -- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file! -- Don't forget to add new modules to your cabal file!
@ -47,12 +50,22 @@ mkYesodDispatch "App" resourcesApp
makeApplication :: AppConfig DefaultEnv Extra -> IO Application makeApplication :: AppConfig DefaultEnv Extra -> IO Application
makeApplication conf = do makeApplication conf = do
foundation <- makeFoundation conf foundation <- makeFoundation conf
-- Initialize the logging middleware
logWare <- mkRequestLogger def
{ outputFormat =
if development
then Detailed True
else Apache FromSocket
, destination = Logger $ appLogger foundation
}
-- Create the WAI application and apply middlewares
app <- toWaiAppPlain foundation app <- toWaiAppPlain foundation
return $ logWare app return $ logWare app
where
logWare = if development then logStdoutDev
else logStdout
-- | Loads up any necessary settings, creates your foundation datatype, and
-- performs some initialization.
makeFoundation :: AppConfig DefaultEnv Extra -> IO App makeFoundation :: AppConfig DefaultEnv Extra -> IO App
makeFoundation conf = do makeFoundation conf = do
manager <- newManager def manager <- newManager def
@ -61,8 +74,15 @@ makeFoundation conf = do
Database.Persist.Store.loadConfig >>= Database.Persist.Store.loadConfig >>=
Database.Persist.Store.applyEnv Database.Persist.Store.applyEnv
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig) p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p logger <- mkLogger True stdout
return $ App conf s p manager dbconf let foundation = App conf s p manager dbconf logger
-- Perform database migration using our application's logging settings.
runLoggingT
(Database.Persist.Store.runPool dbconf (runMigration migrateAll) p)
(messageLoggerSource foundation logger)
return foundation
-- for yesod devel -- for yesod devel
getApplicationDev :: IO (Int, Application) getApplicationDev :: IO (Int, Application)
@ -95,6 +115,7 @@ import Model
import Text.Jasmine (minifym) import Text.Jasmine (minifym)
import Web.ClientSession (getKey) import Web.ClientSession (getKey)
import Text.Hamlet (hamletFile) import Text.Hamlet (hamletFile)
import System.Log.FastLogger (Logger)
-- | The site argument for your application. This can be a good place to -- | The site argument for your application. This can be a good place to
-- keep settings and values requiring initialization before your application -- keep settings and values requiring initialization before your application
@ -106,6 +127,7 @@ data App = App
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool. , connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
, httpManager :: Manager , httpManager :: Manager
, persistConfig :: Settings.PersistConfig , persistConfig :: Settings.PersistConfig
, appLogger :: Logger
} }
-- Set up i18n messages. See the message folder. -- Set up i18n messages. See the message folder.
@ -397,6 +419,9 @@ library
, warp >= 1.3 && < 1.4 , warp >= 1.3 && < 1.4
, data-default , data-default
, aeson , aeson
, conduit >= 1.0
, monad-logger >= 0.3
, fast-logger >= 0.3
executable PROJECTNAME executable PROJECTNAME
if flag(library-only) if flag(library-only)
@ -424,6 +449,7 @@ test-suite test
, persistent , persistent
, persistent-mysql , persistent-mysql
, resourcet , resourcet
, monad-logger
{-# START_FILE Settings.hs #-} {-# START_FILE Settings.hs #-}
-- | Settings are centralized, as much as possible, into this file. This -- | Settings are centralized, as much as possible, into this file. This
@ -5797,15 +5823,18 @@ import Yesod.Test
import Database.Persist hiding (get) import Database.Persist hiding (get)
import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection) import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection)
import Control.Monad.Trans.Resource (ResourceT, runResourceT) import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Model import Model
type Specs = SpecsConn Connection type Specs = SpecsConn Connection
runDB :: SqlPersist (ResourceT IO) a -> OneSpec Connection a runDB :: SqlPersist (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
runDB = runDBRunner poolRunner runDB = runDBRunner poolRunner
where where
poolRunner query pool = runResourceT $ runSqlPool query pool poolRunner query pool = runResourceT
$ runNoLoggingT
$ runSqlPool query pool
{-# START_FILE tests/main.hs #-} {-# START_FILE tests/main.hs #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}

View File

@ -26,10 +26,13 @@ import Yesod.Auth
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Default.Main import Yesod.Default.Main
import Yesod.Default.Handlers import Yesod.Default.Handlers
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev) import Network.Wai.Middleware.RequestLogger
import qualified Database.Persist.Store import qualified Database.Persist.Store
import Database.Persist.GenericSql (runMigration) import Database.Persist.GenericSql (runMigration)
import Network.HTTP.Conduit (newManager, def) import Network.HTTP.Conduit (newManager, def)
import Control.Monad.Logger (runLoggingT)
import System.IO (stdout)
import System.Log.FastLogger (mkLogger)
-- Import all relevant handler modules here. -- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file! -- Don't forget to add new modules to your cabal file!
@ -47,12 +50,22 @@ mkYesodDispatch "App" resourcesApp
makeApplication :: AppConfig DefaultEnv Extra -> IO Application makeApplication :: AppConfig DefaultEnv Extra -> IO Application
makeApplication conf = do makeApplication conf = do
foundation <- makeFoundation conf foundation <- makeFoundation conf
-- Initialize the logging middleware
logWare <- mkRequestLogger def
{ outputFormat =
if development
then Detailed True
else Apache FromSocket
, destination = Logger $ appLogger foundation
}
-- Create the WAI application and apply middlewares
app <- toWaiAppPlain foundation app <- toWaiAppPlain foundation
return $ logWare app return $ logWare app
where
logWare = if development then logStdoutDev
else logStdout
-- | Loads up any necessary settings, creates your foundation datatype, and
-- performs some initialization.
makeFoundation :: AppConfig DefaultEnv Extra -> IO App makeFoundation :: AppConfig DefaultEnv Extra -> IO App
makeFoundation conf = do makeFoundation conf = do
manager <- newManager def manager <- newManager def
@ -61,8 +74,15 @@ makeFoundation conf = do
Database.Persist.Store.loadConfig >>= Database.Persist.Store.loadConfig >>=
Database.Persist.Store.applyEnv Database.Persist.Store.applyEnv
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig) p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p logger <- mkLogger True stdout
return $ App conf s p manager dbconf let foundation = App conf s p manager dbconf logger
-- Perform database migration using our application's logging settings.
runLoggingT
(Database.Persist.Store.runPool dbconf (runMigration migrateAll) p)
(messageLoggerSource foundation logger)
return foundation
-- for yesod devel -- for yesod devel
getApplicationDev :: IO (Int, Application) getApplicationDev :: IO (Int, Application)
@ -95,6 +115,7 @@ import Model
import Text.Jasmine (minifym) import Text.Jasmine (minifym)
import Web.ClientSession (getKey) import Web.ClientSession (getKey)
import Text.Hamlet (hamletFile) import Text.Hamlet (hamletFile)
import System.Log.FastLogger (Logger)
-- | The site argument for your application. This can be a good place to -- | The site argument for your application. This can be a good place to
-- keep settings and values requiring initialization before your application -- keep settings and values requiring initialization before your application
@ -106,6 +127,7 @@ data App = App
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool. , connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
, httpManager :: Manager , httpManager :: Manager
, persistConfig :: Settings.PersistConfig , persistConfig :: Settings.PersistConfig
, appLogger :: Logger
} }
-- Set up i18n messages. See the message folder. -- Set up i18n messages. See the message folder.
@ -397,6 +419,9 @@ library
, warp >= 1.3 && < 1.4 , warp >= 1.3 && < 1.4
, data-default , data-default
, aeson , aeson
, conduit >= 1.0
, monad-logger >= 0.3
, fast-logger >= 0.3
executable PROJECTNAME executable PROJECTNAME
if flag(library-only) if flag(library-only)
@ -424,6 +449,7 @@ test-suite test
, persistent , persistent
, persistent-postgresql , persistent-postgresql
, resourcet , resourcet
, monad-logger
{-# START_FILE Settings.hs #-} {-# START_FILE Settings.hs #-}
-- | Settings are centralized, as much as possible, into this file. This -- | Settings are centralized, as much as possible, into this file. This
@ -5771,15 +5797,18 @@ import Yesod.Test
import Database.Persist hiding (get) import Database.Persist hiding (get)
import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection) import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection)
import Control.Monad.Trans.Resource (ResourceT, runResourceT) import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Model import Model
type Specs = SpecsConn Connection type Specs = SpecsConn Connection
runDB :: SqlPersist (ResourceT IO) a -> OneSpec Connection a runDB :: SqlPersist (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
runDB = runDBRunner poolRunner runDB = runDBRunner poolRunner
where where
poolRunner query pool = runResourceT $ runSqlPool query pool poolRunner query pool = runResourceT
$ runNoLoggingT
$ runSqlPool query pool
{-# START_FILE tests/main.hs #-} {-# START_FILE tests/main.hs #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}

View File

@ -24,8 +24,11 @@ import Import
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Default.Main import Yesod.Default.Main
import Yesod.Default.Handlers import Yesod.Default.Handlers
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev) import Network.Wai.Middleware.RequestLogger
import Network.HTTP.Conduit (newManager, def) import Network.HTTP.Conduit (newManager, def)
import Control.Monad.Logger (runLoggingT)
import System.IO (stdout)
import System.Log.FastLogger (mkLogger)
-- Import all relevant handler modules here. -- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file! -- Don't forget to add new modules to your cabal file!
@ -43,17 +46,30 @@ mkYesodDispatch "App" resourcesApp
makeApplication :: AppConfig DefaultEnv Extra -> IO Application makeApplication :: AppConfig DefaultEnv Extra -> IO Application
makeApplication conf = do makeApplication conf = do
foundation <- makeFoundation conf foundation <- makeFoundation conf
-- Initialize the logging middleware
logWare <- mkRequestLogger def
{ outputFormat =
if development
then Detailed True
else Apache FromSocket
, destination = Logger $ appLogger foundation
}
-- Create the WAI application and apply middlewares
app <- toWaiAppPlain foundation app <- toWaiAppPlain foundation
return $ logWare app return $ logWare app
where
logWare = if development then logStdoutDev
else logStdout
-- | Loads up any necessary settings, creates your foundation datatype, and
-- performs some initialization.
makeFoundation :: AppConfig DefaultEnv Extra -> IO App makeFoundation :: AppConfig DefaultEnv Extra -> IO App
makeFoundation conf = do makeFoundation conf = do
manager <- newManager def manager <- newManager def
s <- staticSite s <- staticSite
return $ App conf s manager logger <- mkLogger True stdout
let foundation = App conf s manager logger
return foundation
-- for yesod devel -- for yesod devel
getApplicationDev :: IO (Int, Application) getApplicationDev :: IO (Int, Application)
@ -80,6 +96,7 @@ import Settings (widgetFile, Extra (..))
import Text.Jasmine (minifym) import Text.Jasmine (minifym)
import Web.ClientSession (getKey) import Web.ClientSession (getKey)
import Text.Hamlet (hamletFile) import Text.Hamlet (hamletFile)
import System.Log.FastLogger (Logger)
-- | The site argument for your application. This can be a good place to -- | The site argument for your application. This can be a good place to
-- keep settings and values requiring initialization before your application -- keep settings and values requiring initialization before your application
@ -89,6 +106,7 @@ data App = App
{ settings :: AppConfig DefaultEnv Extra { settings :: AppConfig DefaultEnv Extra
, getStatic :: Static -- ^ Settings for static file serving. , getStatic :: Static -- ^ Settings for static file serving.
, httpManager :: Manager , httpManager :: Manager
, appLogger :: Logger
} }
-- Set up i18n messages. See the message folder. -- Set up i18n messages. See the message folder.
@ -325,6 +343,9 @@ library
, warp >= 1.3 && < 1.4 , warp >= 1.3 && < 1.4
, data-default , data-default
, aeson , aeson
, conduit >= 1.0
, monad-logger >= 0.3
, fast-logger >= 0.3
executable PROJECTNAME executable PROJECTNAME
if flag(library-only) if flag(library-only)

View File

@ -26,10 +26,13 @@ import Yesod.Auth
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Default.Main import Yesod.Default.Main
import Yesod.Default.Handlers import Yesod.Default.Handlers
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev) import Network.Wai.Middleware.RequestLogger
import qualified Database.Persist.Store import qualified Database.Persist.Store
import Database.Persist.GenericSql (runMigration) import Database.Persist.GenericSql (runMigration)
import Network.HTTP.Conduit (newManager, def) import Network.HTTP.Conduit (newManager, def)
import Control.Monad.Logger (runLoggingT)
import System.IO (stdout)
import System.Log.FastLogger (mkLogger)
-- Import all relevant handler modules here. -- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file! -- Don't forget to add new modules to your cabal file!
@ -47,12 +50,22 @@ mkYesodDispatch "App" resourcesApp
makeApplication :: AppConfig DefaultEnv Extra -> IO Application makeApplication :: AppConfig DefaultEnv Extra -> IO Application
makeApplication conf = do makeApplication conf = do
foundation <- makeFoundation conf foundation <- makeFoundation conf
-- Initialize the logging middleware
logWare <- mkRequestLogger def
{ outputFormat =
if development
then Detailed True
else Apache FromSocket
, destination = Logger $ appLogger foundation
}
-- Create the WAI application and apply middlewares
app <- toWaiAppPlain foundation app <- toWaiAppPlain foundation
return $ logWare app return $ logWare app
where
logWare = if development then logStdoutDev
else logStdout
-- | Loads up any necessary settings, creates your foundation datatype, and
-- performs some initialization.
makeFoundation :: AppConfig DefaultEnv Extra -> IO App makeFoundation :: AppConfig DefaultEnv Extra -> IO App
makeFoundation conf = do makeFoundation conf = do
manager <- newManager def manager <- newManager def
@ -61,8 +74,15 @@ makeFoundation conf = do
Database.Persist.Store.loadConfig >>= Database.Persist.Store.loadConfig >>=
Database.Persist.Store.applyEnv Database.Persist.Store.applyEnv
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig) p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p logger <- mkLogger True stdout
return $ App conf s p manager dbconf let foundation = App conf s p manager dbconf logger
-- Perform database migration using our application's logging settings.
runLoggingT
(Database.Persist.Store.runPool dbconf (runMigration migrateAll) p)
(messageLoggerSource foundation logger)
return foundation
-- for yesod devel -- for yesod devel
getApplicationDev :: IO (Int, Application) getApplicationDev :: IO (Int, Application)
@ -95,6 +115,7 @@ import Model
import Text.Jasmine (minifym) import Text.Jasmine (minifym)
import Web.ClientSession (getKey) import Web.ClientSession (getKey)
import Text.Hamlet (hamletFile) import Text.Hamlet (hamletFile)
import System.Log.FastLogger (Logger)
-- | The site argument for your application. This can be a good place to -- | The site argument for your application. This can be a good place to
-- keep settings and values requiring initialization before your application -- keep settings and values requiring initialization before your application
@ -106,6 +127,7 @@ data App = App
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool. , connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
, httpManager :: Manager , httpManager :: Manager
, persistConfig :: Settings.PersistConfig , persistConfig :: Settings.PersistConfig
, appLogger :: Logger
} }
-- Set up i18n messages. See the message folder. -- Set up i18n messages. See the message folder.
@ -397,6 +419,9 @@ library
, warp >= 1.3 && < 1.4 , warp >= 1.3 && < 1.4
, data-default , data-default
, aeson , aeson
, conduit >= 1.0
, monad-logger >= 0.3
, fast-logger >= 0.3
executable PROJECTNAME executable PROJECTNAME
if flag(library-only) if flag(library-only)
@ -424,6 +449,7 @@ test-suite test
, persistent , persistent
, persistent-sqlite , persistent-sqlite
, resourcet , resourcet
, monad-logger
{-# START_FILE Settings.hs #-} {-# START_FILE Settings.hs #-}
-- | Settings are centralized, as much as possible, into this file. This -- | Settings are centralized, as much as possible, into this file. This
@ -5767,15 +5793,18 @@ import Yesod.Test
import Database.Persist hiding (get) import Database.Persist hiding (get)
import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection) import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection)
import Control.Monad.Trans.Resource (ResourceT, runResourceT) import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Model import Model
type Specs = SpecsConn Connection type Specs = SpecsConn Connection
runDB :: SqlPersist (ResourceT IO) a -> OneSpec Connection a runDB :: SqlPersist (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
runDB = runDBRunner poolRunner runDB = runDBRunner poolRunner
where where
poolRunner query pool = runResourceT $ runSqlPool query pool poolRunner query pool = runResourceT
$ runNoLoggingT
$ runSqlPool query pool
{-# START_FILE tests/main.hs #-} {-# START_FILE tests/main.hs #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}