diff --git a/test/Handler/AppSpec.hs b/test/Handler/AppSpec.hs new file mode 100644 index 0000000..5092972 --- /dev/null +++ b/test/Handler/AppSpec.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE TypeFamilies #-} + +module Handler.AppSpec (spec) where + +import Startlude +import TestImport + +spec :: Spec +spec = do + describe "GET /apps" $ do + withApp $ it "returns list of apps" $ do + request $ do + setMethod "GET" + setUrl ("/apps" :: Text) + printBody + bodyContains "" + statusIs 200 + + + diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 0000000..37c4d99 --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,11 @@ +module Main where + +import Test.Hspec.Runner +import qualified Spec +import Test.Hspec.Formatters +import qualified Handler.AppSpec as A + +main :: IO () +main = do + _ <- A.spec + hspecWith defaultConfig { configFormatter = Just progress } Spec.spec diff --git a/test/TestImport.hs b/test/TestImport.hs new file mode 100644 index 0000000..d0b6752 --- /dev/null +++ b/test/TestImport.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE QuasiQuotes #-} + +module TestImport + ( module TestImport + , module X + ) where + +import Startlude +import Application (makeFoundation, makeLogWare) +import Foundation as X +import Test.Hspec as X +import Yesod.Default.Config2 (useEnv, loadYamlSettings) +import Yesod.Test as X +import Yesod.Core.Unsafe (fakeHandlerGetLogger) + +runHandler :: Handler a -> YesodExample AgentCtx a +runHandler handler = do + app <- getTestYesod + fakeHandlerGetLogger appLogger app handler + +withApp :: SpecWith (TestApp AgentCtx) -> Spec +withApp = before $ do + settings <- loadYamlSettings + ["config/settings.yml"] + [] + useEnv + foundation <- makeFoundation settings + logWare <- liftIO $ makeLogWare foundation + return (foundation, logWare) \ No newline at end of file