Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: insignificant JSON whitespace on writes #3315

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/spec/Feature/Query/InsertSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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" $
Expand Down
9 changes: 9 additions & 0 deletions test/spec/Feature/Query/UpdateSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading