tests: don't match JSON bodies literally
The change of hash function with hashable-1.3.1.0 changes object ordering in JSON output, causing some test failures: https://app.circleci.com/pipelines/github/PostgREST/postgrest/805/workflows/067844c9-9ce4-49e8-8790-315625ab309b/jobs/8309 e.g.: > expected: "[{\"b\":\"baz\",\"a\":\"bar\"}]" > but got: "[{\"a\":\"bar\",\"b\":\"baz\"}]" This changes the tests to not compare against the body literally, and instead use the ResponseMatcher instance from Test.Hspec.Wai.JSON.
This commit is contained in:
committed by
Steve Chavez
parent
5baec4819f
commit
3a466aea9a
+7
-1
@@ -8,7 +8,7 @@ import qualified Data.Set as S
|
||||
import qualified System.IO.Error as E
|
||||
|
||||
import Data.Aeson (Value (..), decode, encode)
|
||||
import Data.CaseInsensitive (CI (..))
|
||||
import Data.CaseInsensitive (CI (..), original)
|
||||
import Data.List (lookup)
|
||||
import Data.List.NonEmpty (fromList)
|
||||
import Network.Wai.Test (SResponse (simpleBody, simpleHeaders, simpleStatus))
|
||||
@@ -33,6 +33,12 @@ matchContentTypeJson = "Content-Type" <:> "application/json; charset=utf-8"
|
||||
matchContentTypeSingular :: MatchHeader
|
||||
matchContentTypeSingular = "Content-Type" <:> "application/vnd.pgrst.object+json; charset=utf-8"
|
||||
|
||||
matchHeaderAbsent :: HeaderName -> MatchHeader
|
||||
matchHeaderAbsent name = MatchHeader $ \headers _body ->
|
||||
case lookup name headers of
|
||||
Just _ -> Just $ "unexpected header: " <> toS (original name) <> "\n"
|
||||
Nothing -> Nothing
|
||||
|
||||
validateOpenApiResponse :: [Header] -> WaiSession () ()
|
||||
validateOpenApiResponse headers = do
|
||||
r <- request methodGet "/" headers ""
|
||||
|
||||
Reference in New Issue
Block a user