Skip to content

Commit

Permalink
new hashable version changed the key ordering in aeson
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen committed Feb 23, 2021
1 parent 89fd708 commit 774ccb8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion servant-docs/test/Servant/DocsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ spec = describe "Servant.Docs" $ do
md `shouldContain` "- This endpoint is sensitive to the value of the **X-Test** HTTP header."

it "contains response samples" $
md `shouldContain` "{\"dt1field1\":\"field 1\",\"dt1field2\":13}"
-- aeson does not guarantee a stable key ordering
md `shouldContainOneOf`
[ "{\"dt1field2\":13,\"dt1field1\":\"field 1\"}"
, "{\"dt1field1\":\"field 1\",\"dt1field2\":13}"
]
it "contains request body samples" $
md `shouldContain` "17"

Expand Down Expand Up @@ -206,6 +210,9 @@ shouldBe = (@?=)
shouldContain :: (Eq a, Show a, HasCallStack) => [a] -> [a] -> Assertion
shouldContain = compareWith (flip isInfixOf) "does not contain"

shouldContainOneOf :: (Eq a, Show a, HasCallStack) => [a] -> [[a]] -> Assertion
shouldContainOneOf = compareWith (any . flip isInfixOf) "does not contain one of"

shouldNotContain :: (Eq a, Show a, HasCallStack) => [a] -> [a] -> Assertion
shouldNotContain = compareWith (\x y -> not (isInfixOf y x)) "contains"

Expand Down

0 comments on commit 774ccb8

Please sign in to comment.