Skip to content

Commit 61ecb0b

Browse files
author
lyxia
committed
Add tests for tracking JSONPath
1 parent 6855372 commit 61ecb0b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/UnitTests.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ camelFrom c s = let (p:ps) = split c s
8686
data Wibble = Wibble {
8787
wibbleString :: String
8888
, wibbleInt :: Int
89-
} deriving (Generic, Show)
89+
} deriving (Generic, Show, Eq)
90+
91+
instance FromJSON Wibble
9092

9193
instance ToJSON Wibble where
9294
toJSON = genericToJSON defaultOptions
@@ -263,6 +265,10 @@ jsonPath = [
263265
, assertEqual "Seq a"
264266
(Left "Error in $[2]: expected Int, encountered Boolean")
265267
(eitherDecode "[0,1,true]" :: Either String (Seq Int))
268+
, assertEqual "Wibble"
269+
(Left "Error in $.wibbleInt: expected Int, encountered Boolean")
270+
(eitherDecode "{\"wibbleString\":\"\",\"wibbleInt\":true}"
271+
:: Either String Wibble)
266272
]
267273

268274
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)