We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

TestHandler.hs 963 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}

module TestHandler where

import Import

import Control.Concurrent.STM

import Yesod.Default.Config
import Network.Wai.Logger
import System.Log.FastLogger
import Yesod.Core.Types



testHandler :: Handler a -> IO (Either ErrorResponse a)
testHandler handler = do
    events <- atomically newTChan :: IO (TChan SnowdriftEvent)
    logger_set <- System.Log.FastLogger.newStderrLoggerSet 4096

    let extra = Extra "copyright" "sourcerepo" (Just "ghrepo") "siteproject" Nothing
        config = AppConfig Development 3000 "http://localhost:3000" (error "HostPreferences") extra
23
        app = App (return ()) config (error "StaticSettings") (error "PersistConfigPool") (error "Manager") (error "PersistConf") (error "Logger") events (const [])
24 25 26 27 28 29 30

    (date_getter, date_updater) <- Network.Wai.Logger.clockDateCacher

    date_updater

    runFakeHandler mempty (const $ Logger logger_set date_getter) app handler