Skip to content

Commit

Permalink
Testing NMParseErrors is sad...
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Sep 25, 2024
1 parent f7d35eb commit efcfb7e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Data.Thyme.Time.Core ( fromGregorian )
import Model.Karen ( parse )
import qualified Model.Linsen as L ( parse )
import Model.Types ( Menu(..)
, NoMenu( NoLunch )
, NoMenu( NoLunch, NMParseError )
)
import Model.Wijkanders ( getWijkanders
, hasDate
Expand All @@ -27,6 +27,10 @@ testFun = \case
either
(assertFailure . mappend "This is not expected, input was:\n" . show)
(@?= e)
Left (NMParseError e _) ->
either
((@?= e) . \(NMParseError e1 _) -> e1)
(assertFailure . mappend "This is not expected, input was:\n" . show)
Left e ->
either
(@?= e)
Expand Down Expand Up @@ -101,7 +105,7 @@ main = hspec $ do
"parses a blob of JSON without error, that has no lunch"
(do
s2 <- BL.readFile "test/linsen2.json" -- Test that has no lunch
testFun (Left NoLunch)
testFun (Left (NMParseError "Error in $: Unable to parse day" undefined))
(L.parse
(fromGregorian 2024 06 06)
(fromJust $ decode s2))
Expand All @@ -112,7 +116,7 @@ main = hspec $ do
"parses a blob of JSON without error, that has the wrong week"
(do
s3 <- BL.readFile "test/linsen3.json"
testFun (Left NoLunch)
testFun (Left (NMParseError "Error in $: Unable to parse day" undefined))
(L.parse
(fromGregorian 2024 06 26)
(fromJust $ decode s3))
Expand Down

0 comments on commit efcfb7e

Please sign in to comment.