Skip to content

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangwalther committed Jul 14, 2020
1 parent 20907ae commit 2f392d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
21 changes: 7 additions & 14 deletions test/Feature/RpcSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,6 @@ spec actualPgVersion =
[json|"Hi"|]
{ matchHeaders = [matchContentTypeJson] }

it "works with inout argument" $
post "/rpc/inout_argument"
[json| { "arg": true } |]
`shouldRespondWith`
[json| true |]
{ matchHeaders = [matchContentTypeJson] }

it "works with variadic arguments" $
post "/rpc/variadic_argument"
[json| { "v": ["hello"] } |]
`shouldRespondWith`
[json|"Hi"|]
{ matchHeaders = [matchContentTypeJson] }

it "parses embedded JSON arguments as JSON" $
post "/rpc/json_argument"
[json| { "arg": { "key": 3 } } |]
Expand Down Expand Up @@ -408,6 +394,13 @@ spec actualPgVersion =
get "/rpc/many_inout_params?num=1&str=two&b=false" `shouldRespondWith`
[json| [{"num":1,"str":"two","b":false}]|] { matchHeaders = [matchContentTypeJson] }

it "works with variadic parameter" $
post "/rpc/variadic_param"
[json| { "v": ["hello"] } |]
`shouldRespondWith`
[json|"Hi"|]
{ matchHeaders = [matchContentTypeJson] }

it "can handle procs with args that have a DEFAULT value" $ do
get "/rpc/many_inout_params?num=1&str=two" `shouldRespondWith`
[json| [{"num":1,"str":"two","b":true}]|] { matchHeaders = [matchContentTypeJson] }
Expand Down
17 changes: 5 additions & 12 deletions test/fixtures/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,6 @@ $_$An RPC function
Just a test for RPC function arguments$_$;


CREATE FUNCTION inout_argument(INOUT arg BOOLEAN)
LANGUAGE SQL AS $_$
SELECT arg
$_$;


CREATE FUNCTION variadic_argument(VARIADIC v TEXT[]) RETURNS text
LANGUAGE SQL AS $_$
SELECT 'Hi'::text
$_$;


CREATE FUNCTION json_argument(arg json) RETURNS text

LANGUAGE sql
Expand Down Expand Up @@ -1084,6 +1072,11 @@ create function test.many_inout_params(INOUT num int, INOUT str text, INOUT b bo
select num, str, b;
$$ language sql;

CREATE FUNCTION test.variadic_param(VARIADIC v TEXT[]) RETURNS text
LANGUAGE SQL AS $_$
SELECT 'Hi'::text
$_$;

create or replace function test.raise_pt402() returns void as $$
begin
raise sqlstate 'PT402' using message = 'Payment Required',
Expand Down

0 comments on commit 2f392d7

Please sign in to comment.