From 5fb72a06a1b64d6cc4a92ed8af07e20b94de4adb Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Wed, 27 Sep 2023 09:22:24 +0200 Subject: [PATCH] add test error by sol --- test/Web/ScottySpec.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/Web/ScottySpec.hs b/test/Web/ScottySpec.hs index bd8dd486..943bc410 100644 --- a/test/Web/ScottySpec.hs +++ b/test/Web/ScottySpec.hs @@ -116,9 +116,13 @@ spec = do large `shouldRespondWith` 413 describe "ActionM" $ do - withApp (Scotty.get "/" $ (undefined `EL.catch` ((\_ -> html "") :: E.SomeException -> ActionM ()))) $ do - it "has a MonadBaseControl instance" $ do - get "/" `shouldRespondWith` 200 + context "MonadBaseControl instance" $ do + withApp (Scotty.get "/" $ (undefined `EL.catch` ((\_ -> html "") :: E.SomeException -> ActionM ()))) $ do + it "catches SomeException and returns 200" $ do + get "/" `shouldRespondWith` 200 + withApp (Scotty.get "/" $ EL.throwIO E.DivideByZero) $ do + it "returns 500 on uncaught exceptions" $ do + get "/" `shouldRespondWith` "

500 Internal Server Error

divide by zero" {matchStatus = 500} withApp (Scotty.get "/dictionary" $ empty <|> queryParam "word1" <|> empty <|> queryParam "word2" >>= text) $ it "has an Alternative instance" $ do