fix: HTTP status responses for upserts

* PUT returns 201 instead of 200 when rows are inserted
* POST with "Prefer: resolution=merge-duplicates" returns 200 instead of 201 when no rows are inserted
This commit is contained in:
Taimoor Zaeem
2023-10-26 20:49:20 -05:00
committed by GitHub
parent 82b38341bf
commit 5c9c7f4ff4
12 changed files with 97 additions and 42 deletions
@@ -225,13 +225,11 @@ spec =
it "succeeds on PUT on the v2 schema" $
request methodPut "/children?id=eq.111" [("Content-Profile", "v2"), ("Prefer", "return=representation")]
[json| [ { "id": 111, "name": "child v2-111", "parent_id": null } ]|]
[json|[{"id": 111, "name": "child v2-111", "parent_id": null}]|]
`shouldRespondWith`
[json|[{ "id": 111, "name": "child v2-111", "parent_id": null }]|]
{
matchStatus = 200
, matchHeaders = [matchContentTypeJson, "Content-Profile" <:> "v2"]
}
[json|[{"id": 111, "name": "child v2-111", "parent_id": null}]|]
{ matchStatus = 201
, matchHeaders = [matchContentTypeJson, "Content-Profile" <:> "v2"]}
context "OpenAPI output" $ do
it "succeeds in reading table definition from default schema v1 if no schema is selected via header" $ do