test: insignificant JSON whitespace on writes

This commit is contained in:
steve-chavez
2024-03-07 17:14:16 -05:00
committed by Steve Chavez
parent 8eb88ef218
commit 05cdbb34c2
2 changed files with 25 additions and 0 deletions
+16
View File
@@ -400,6 +400,22 @@ spec actualPgVersion = do
`shouldRespondWith` [json|[{ id: 20 }]|]
{ matchStatus = 201 }
context "insignificant whitespace" $ do
it "ignores it and successfuly inserts with json payload" $ do
request methodPost "/json_table"
[("Prefer", "return=representation")]
"\t \n \r { \"data\": { \"foo\":\"bar\" } }\t \n \r "
`shouldRespondWith` [json|[{"data":{"foo":"bar"}}]|]
{ matchStatus = 201
}
request methodPost "/json_table"
[("Prefer", "return=representation")]
"\t \n \r [{ \"data\": { \"foo\":\"bar\" } }, \t \n \r {\"data\": 34}]\t \n \r "
`shouldRespondWith` [json|[{"data":{"foo":"bar"}}, {"data":34}]|]
{ matchStatus = 201
}
-- https://github.com/PostgREST/postgrest/issues/2861
context "bit and char columns with length" $ do
it "should insert to a bit column with length" $
+9
View File
@@ -58,6 +58,15 @@ spec actualPgVersion = do
matchHeaders = [matchContentTypeJson]
}
context "insignificant whitespace" $ do
it "ignores it and successfuly updates with json payload" $ do
request methodPatch "/items?id=eq.1"
[("Prefer", "return=representation")]
"\t \n \r { \"id\": 99 } \t \n \r "
`shouldRespondWith` [json|[{"id":99}]|]
{ matchStatus = 200
}
context "in a nonempty table" $ do
it "can update a single item" $ do
patch "/items?id=eq.2"