@@ -20,22 +20,22 @@ void main() {
20
20
});
21
21
test ('function throws' , () async {
22
22
try {
23
- await functionsCustomHttpClient.invoke ('function' );
23
+ await functionsCustomHttpClient.invoke ('error- function' );
24
24
fail ('should throw' );
25
25
} on FunctionException catch (e) {
26
26
expect (e.status, 420 );
27
27
}
28
28
});
29
29
30
30
test ('function call' , () async {
31
- final res = await functionsCustomHttpClient.invoke ('function1 ' );
31
+ final res = await functionsCustomHttpClient.invoke ('function ' );
32
32
expect (res.data, {'key' : 'Hello World' });
33
33
expect (res.status, 200 );
34
34
});
35
35
36
36
test ('function call with query parameters' , () async {
37
37
final res = await functionsCustomHttpClient
38
- .invoke ('function1 ' , queryParameters: {'key' : 'value' });
38
+ .invoke ('function ' , queryParameters: {'key' : 'value' });
39
39
40
40
final request = customHttpClient.receivedRequests.last;
41
41
@@ -48,7 +48,7 @@ void main() {
48
48
final fileName = "file.txt" ;
49
49
final fileContent = "Hello World" ;
50
50
final res = await functionsCustomHttpClient.invoke (
51
- 'function1 ' ,
51
+ 'function ' ,
52
52
queryParameters: {'key' : 'value' },
53
53
files: [
54
54
MultipartFile .fromString (fileName, fileContent),
@@ -78,7 +78,7 @@ void main() {
78
78
);
79
79
80
80
await client.dispose ();
81
- final res = await client.invoke ('function1 ' );
81
+ final res = await client.invoke ('function ' );
82
82
expect (res.data, {'key' : 'Hello World' });
83
83
});
84
84
@@ -90,5 +90,60 @@ void main() {
90
90
['a' , 'b' , 'c' ],
91
91
));
92
92
});
93
+
94
+ group ('body encoding' , () {
95
+ test ('integer properly encoded' , () async {
96
+ await functionsCustomHttpClient.invoke ('function' , body: 42 );
97
+
98
+ final req = customHttpClient.receivedRequests.last;
99
+ expect (req, isA <Request >());
100
+
101
+ req as Request ;
102
+ expect (req.body, '42' );
103
+ });
104
+
105
+ test ('double is properly encoded' , () async {
106
+ await functionsCustomHttpClient.invoke ('function' , body: 42.9 );
107
+
108
+ final req = customHttpClient.receivedRequests.last;
109
+ expect (req, isA <Request >());
110
+
111
+ req as Request ;
112
+ expect (req.body, '42.9' );
113
+ });
114
+
115
+ test ('string is properly encoded' , () async {
116
+ await functionsCustomHttpClient.invoke ('function' , body: 'ExampleText' );
117
+
118
+ final req = customHttpClient.receivedRequests.last;
119
+ expect (req, isA <Request >());
120
+
121
+ req as Request ;
122
+ expect (req.body, 'ExampleText' );
123
+ });
124
+
125
+ test ('list is properly encoded' , () async {
126
+ await functionsCustomHttpClient.invoke ('function' , body: [1 , 2 , 3 ]);
127
+
128
+ final req = customHttpClient.receivedRequests.last;
129
+ expect (req, isA <Request >());
130
+
131
+ req as Request ;
132
+ expect (req.body, '[1,2,3]' );
133
+ });
134
+
135
+ test ('map is properly encoded' , () async {
136
+ await functionsCustomHttpClient.invoke (
137
+ 'function' ,
138
+ body: {'thekey' : 'thevalue' },
139
+ );
140
+
141
+ final req = customHttpClient.receivedRequests.last;
142
+ expect (req, isA <Request >());
143
+
144
+ req as Request ;
145
+ expect (req.body, '{"thekey":"thevalue"}' );
146
+ });
147
+ });
93
148
});
94
149
}
0 commit comments