@@ -63,6 +63,29 @@ void main() {
63
63
expect (res, isA <int >());
64
64
});
65
65
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
+
66
89
test ('custom headers' , () async {
67
90
final postgrest = PostgrestClient (rootUrl, headers: {'apikey' : 'foo' });
68
91
expect (postgrest.headers['apikey' ], 'foo' );
@@ -448,10 +471,12 @@ void main() {
448
471
});
449
472
});
450
473
group ("Custom http client" , () {
474
+ CustomHttpClient customHttpClient = CustomHttpClient ();
451
475
setUp (() {
476
+ customHttpClient = CustomHttpClient ();
452
477
postgrestCustomHttpClient = PostgrestClient (
453
478
rootUrl,
454
- httpClient: CustomHttpClient () ,
479
+ httpClient: customHttpClient ,
455
480
);
456
481
});
457
482
@@ -486,6 +511,23 @@ void main() {
486
511
'Stored procedure was able to be called, even tho it does not exist' );
487
512
} on PostgrestException catch (error) {
488
513
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);
489
531
}
490
532
});
491
533
});
0 commit comments