@@ -63,6 +63,29 @@ void main() {
6363 expect (res, isA <int >());
6464 });
6565
66+ test ('stored procedure with array parameter' , () async {
67+ final res = await postgrest.rpc <int >(
68+ 'get_array_element' ,
69+ params: {
70+ 'arr' : [37 , 420 , 64 ],
71+ 'index' : 2
72+ },
73+ );
74+ expect (res, 420 );
75+ });
76+
77+ test ('stored procedure with read-only access mode' , () async {
78+ final res = await postgrest.rpc <int >(
79+ 'get_array_element' ,
80+ params: {
81+ 'arr' : [37 , 420 , 64 ],
82+ 'index' : 2
83+ },
84+ get : true ,
85+ );
86+ expect (res, 420 );
87+ });
88+
6689 test ('custom headers' , () async {
6790 final postgrest = PostgrestClient (rootUrl, headers: {'apikey' : 'foo' });
6891 expect (postgrest.headers['apikey' ], 'foo' );
@@ -448,10 +471,12 @@ void main() {
448471 });
449472 });
450473 group ("Custom http client" , () {
474+ CustomHttpClient customHttpClient = CustomHttpClient ();
451475 setUp (() {
476+ customHttpClient = CustomHttpClient ();
452477 postgrestCustomHttpClient = PostgrestClient (
453478 rootUrl,
454- httpClient: CustomHttpClient () ,
479+ httpClient: customHttpClient ,
455480 );
456481 });
457482
@@ -486,6 +511,23 @@ void main() {
486511 'Stored procedure was able to be called, even tho it does not exist' );
487512 } on PostgrestException catch (error) {
488513 expect (error.code, '420' );
514+ expect (customHttpClient.lastRequest? .method, "POST" );
515+ }
516+ });
517+
518+ test ('stored procedure call in read-only access mode' , () async {
519+ try {
520+ await postgrestCustomHttpClient.rpc <String >(
521+ 'get_status' ,
522+ params: {'name_param' : 'supabot' },
523+ get : true ,
524+ );
525+ fail (
526+ 'Stored procedure was able to be called, even tho it does not exist' );
527+ } on PostgrestException catch (error) {
528+ expect (error.code, '420' );
529+ expect (customHttpClient.lastRequest? .method, "GET" );
530+ expect (customHttpClient.lastBody, isEmpty);
489531 }
490532 });
491533 });
0 commit comments