Include cors middleware in test
This commit is contained in:
+5
-3
@@ -21,10 +21,10 @@ import Data.CaseInsensitive (CI(..))
|
|||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Text.Regex.TDFA ((=~))
|
import Text.Regex.TDFA ((=~))
|
||||||
import qualified Data.ByteString.Char8 as BS
|
import qualified Data.ByteString.Char8 as BS
|
||||||
-- import Network.Wai.Middleware.Cors (cors)
|
import Network.Wai.Middleware.Cors (cors)
|
||||||
|
|
||||||
import App (app, sqlErrHandler, isSqlError)
|
import App (app, sqlErrHandler, isSqlError)
|
||||||
-- import Config (corsPolicy, AppConfig(..))
|
import Config (corsPolicy)
|
||||||
-- import Auth (addUser)
|
-- import Auth (addUser)
|
||||||
|
|
||||||
isLeft :: Either a b -> Bool
|
isLeft :: Either a b -> Bool
|
||||||
@@ -42,12 +42,14 @@ pgSettings = H.Postgres "localhost" 5432 "dbapi_test" "" "dbapi_test"
|
|||||||
|
|
||||||
withApp :: ActionWith Application -> IO ()
|
withApp :: ActionWith Application -> IO ()
|
||||||
withApp perform =
|
withApp perform =
|
||||||
perform $ \req resp ->
|
perform $ middle $ \req resp ->
|
||||||
H.session pgSettings testSettings $ do
|
H.session pgSettings testSettings $ do
|
||||||
session' <- flip runReaderT <$> ask
|
session' <- flip runReaderT <$> ask
|
||||||
liftIO $ resp =<< catchJust isSqlError (session' $ app req)
|
liftIO $ resp =<< catchJust isSqlError (session' $ app req)
|
||||||
sqlErrHandler
|
sqlErrHandler
|
||||||
|
|
||||||
|
where middle = cors corsPolicy
|
||||||
|
|
||||||
rangeHdrs :: ByteRange -> [Header]
|
rangeHdrs :: ByteRange -> [Header]
|
||||||
rangeHdrs r = [rangeUnit, (hRange, renderByteRange r)]
|
rangeHdrs r = [rangeUnit, (hRange, renderByteRange r)]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user