RPC POST for function w/single unnamed XML param

This commit is contained in:
Franz-Josef Färber
2022-06-03 11:52:57 -05:00
committed by Steve Chavez
parent d14f745406
commit 807364bd7b
6 changed files with 48 additions and 3 deletions
+37
View File
@@ -1202,6 +1202,13 @@ spec actualPgVersion =
`shouldRespondWith`
[str|unnamed text arg|]
it "can insert xml directly" $
request methodPost "/rpc/unnamed_xml_param"
[("Content-Type", "text/xml"), ("Accept", "text/xml")]
[str|<note><from>John</from><to>Jane</to><message>Remember me</message></note>|]
`shouldRespondWith`
[str|<note><from>John</from><to>Jane</to><message>Remember me</message></note>|]
it "can insert bytea directly" $ do
let file = unsafePerformIO $ BL.readFile "test/spec/fixtures/image.png"
r <- request methodPost "/rpc/unnamed_bytea_param"
@@ -1240,6 +1247,21 @@ spec actualPgVersion =
, matchHeaders = [ matchContentTypeJson ]
}
it "will err when no function with single unnamed text parameter exists and text/xml is specified" $
request methodPost "/rpc/unnamed_int_param"
[("Content-Type", "text/xml")]
[str|a simple text|]
`shouldRespondWith`
[json|{
"hint": "If a new function was created in the database with this name and parameters, try reloading the schema cache.",
"message": "Could not find the test.unnamed_int_param function with a single unnamed xml parameter in the schema cache",
"code":"PGRST202",
"details":null
}|]
{ matchStatus = 404
, matchHeaders = [ matchContentTypeJson ]
}
it "will err when no function with single unnamed bytea parameter exists and application/octet-stream is specified" $
let file = unsafePerformIO $ BL.readFile "test/spec/fixtures/image.png" in
request methodPost "/rpc/unnamed_int_param"
@@ -1329,3 +1351,18 @@ spec actualPgVersion =
{ matchStatus = 300
, matchHeaders = [matchContentTypeJson]
}
it "should fail on /rpc/unnamed_xml_param when posting invalid xml" $ do
request methodPost "/rpc/unnamed_xml_param"
[("Content-Type", "text/xml"), ("Accept", "text/xml")]
[str|<|]
`shouldRespondWith`
[json| {
"hint":null,
"message":"invalid XML content",
"code":"2200N",
"details":"line 1: StartTag: invalid element name\n<\n ^"
}|]
{ matchStatus = 400
, matchHeaders = [matchContentTypeJson]
}