@@ -34,18 +34,18 @@ void main() {
34
34
});
35
35
}
36
36
37
- checkRequest (null , '/api/v1/example/route' );
38
- checkRequest ({}, '/api/v1/example/route?' );
39
- checkRequest ({'x' : 3 }, '/api/v1/example/route?x=3' );
40
- checkRequest ({'x' : 3 , 'y' : 4 }, '/api/v1/example/route?x=3&y=4' );
41
- checkRequest ({'x' : null }, '/api/v1/example/route?x=null' );
42
- checkRequest ({'x' : true }, '/api/v1/example/route?x=true' );
43
- checkRequest ({'x' : 'foo' }, '/api/v1/example/route?x=%22foo%22' );
44
- checkRequest ({'x' : [1 , 2 ]}, '/api/v1/example/route?x=%5B1%2C2%5D' );
45
- checkRequest ({'x' : {'y' : 1 }}, '/api/v1/example/route?x=%7B%22y%22%3A1%7D' );
46
- checkRequest ({'x' : RawParameter ('foo' )},
37
+ await checkRequest (null , '/api/v1/example/route' );
38
+ await checkRequest ({}, '/api/v1/example/route?' );
39
+ await checkRequest ({'x' : 3 }, '/api/v1/example/route?x=3' );
40
+ await checkRequest ({'x' : 3 , 'y' : 4 }, '/api/v1/example/route?x=3&y=4' );
41
+ await checkRequest ({'x' : null }, '/api/v1/example/route?x=null' );
42
+ await checkRequest ({'x' : true }, '/api/v1/example/route?x=true' );
43
+ await checkRequest ({'x' : 'foo' }, '/api/v1/example/route?x=%22foo%22' );
44
+ await checkRequest ({'x' : [1 , 2 ]}, '/api/v1/example/route?x=%5B1%2C2%5D' );
45
+ await checkRequest ({'x' : {'y' : 1 }}, '/api/v1/example/route?x=%7B%22y%22%3A1%7D' );
46
+ await checkRequest ({'x' : RawParameter ('foo' )},
47
47
'/api/v1/example/route?x=foo' );
48
- checkRequest ({'x' : RawParameter ('foo' ), 'y' : 'bar' },
48
+ await checkRequest ({'x' : RawParameter ('foo' ), 'y' : 'bar' },
49
49
'/api/v1/example/route?x=foo&y=%22bar%22' );
50
50
});
51
51
@@ -67,17 +67,17 @@ void main() {
67
67
});
68
68
}
69
69
70
- checkRequest (null , '' , expectContentType: false );
71
- checkRequest ({}, '' );
72
- checkRequest ({'x' : 3 }, 'x=3' );
73
- checkRequest ({'x' : 3 , 'y' : 4 }, 'x=3&y=4' );
74
- checkRequest ({'x' : null }, 'x=null' );
75
- checkRequest ({'x' : true }, 'x=true' );
76
- checkRequest ({'x' : 'foo' }, 'x=%22foo%22' );
77
- checkRequest ({'x' : [1 , 2 ]}, 'x=%5B1%2C2%5D' );
78
- checkRequest ({'x' : {'y' : 1 }}, 'x=%7B%22y%22%3A1%7D' );
79
- checkRequest ({'x' : RawParameter ('foo' )}, 'x=foo' );
80
- checkRequest ({'x' : RawParameter ('foo' ), 'y' : 'bar' }, 'x=foo&y=%22bar%22' );
70
+ await checkRequest (null , '' , expectContentType: false );
71
+ await checkRequest ({}, '' );
72
+ await checkRequest ({'x' : 3 }, 'x=3' );
73
+ await checkRequest ({'x' : 3 , 'y' : 4 }, 'x=3&y=4' );
74
+ await checkRequest ({'x' : null }, 'x=null' );
75
+ await checkRequest ({'x' : true }, 'x=true' );
76
+ await checkRequest ({'x' : 'foo' }, 'x=%22foo%22' );
77
+ await checkRequest ({'x' : [1 , 2 ]}, 'x=%5B1%2C2%5D' );
78
+ await checkRequest ({'x' : {'y' : 1 }}, 'x=%7B%22y%22%3A1%7D' );
79
+ await checkRequest ({'x' : RawParameter ('foo' )}, 'x=foo' );
80
+ await checkRequest ({'x' : RawParameter ('foo' ), 'y' : 'bar' }, 'x=foo&y=%22bar%22' );
81
81
});
82
82
83
83
test ('ApiConnection.postFileFromStream' , () async {
@@ -111,18 +111,18 @@ void main() {
111
111
});
112
112
}
113
113
114
- checkRequest ([], 0 , filename: null );
115
- checkRequest (['asdf' .codeUnits], 4 , filename: null );
116
- checkRequest (['asd' .codeUnits, 'f' .codeUnits], 4 , filename: null );
114
+ await checkRequest ([], 0 , filename: null );
115
+ await checkRequest (['asdf' .codeUnits], 4 , filename: null );
116
+ await checkRequest (['asd' .codeUnits, 'f' .codeUnits], 4 , filename: null );
117
117
118
- checkRequest (['asdf' .codeUnits], 4 , filename: 'info.txt' );
119
- checkRequest (['asdf' .codeUnits], 4 ,
118
+ await checkRequest (['asdf' .codeUnits], 4 , filename: 'info.txt' );
119
+ await checkRequest (['asdf' .codeUnits], 4 ,
120
120
filename: 'image.jpg' , contentType: 'image/jpeg' );
121
- checkRequest (['asdf' .codeUnits], 4 ,
121
+ await checkRequest (['asdf' .codeUnits], 4 ,
122
122
filename: 'image.jpg' , contentType: 'asdfjkl;' , isContentTypeInvalid: true );
123
123
124
- checkRequest (['asdf' .codeUnits], 1 , filename: null ); // nothing on client side catches a wrong length
125
- checkRequest (['asdf' .codeUnits], 100 , filename: null );
124
+ await checkRequest (['asdf' .codeUnits], 1 , filename: null ); // nothing on client side catches a wrong length
125
+ await checkRequest (['asdf' .codeUnits], 100 , filename: null );
126
126
});
127
127
128
128
test ('ApiConnection.delete' , () async {
@@ -143,17 +143,17 @@ void main() {
143
143
});
144
144
}
145
145
146
- checkRequest (null , '' , expectContentType: false );
147
- checkRequest ({}, '' );
148
- checkRequest ({'x' : 3 }, 'x=3' );
149
- checkRequest ({'x' : 3 , 'y' : 4 }, 'x=3&y=4' );
150
- checkRequest ({'x' : null }, 'x=null' );
151
- checkRequest ({'x' : true }, 'x=true' );
152
- checkRequest ({'x' : 'foo' }, 'x=%22foo%22' );
153
- checkRequest ({'x' : [1 , 2 ]}, 'x=%5B1%2C2%5D' );
154
- checkRequest ({'x' : {'y' : 1 }}, 'x=%7B%22y%22%3A1%7D' );
155
- checkRequest ({'x' : RawParameter ('foo' )}, 'x=foo' );
156
- checkRequest ({'x' : RawParameter ('foo' ), 'y' : 'bar' }, 'x=foo&y=%22bar%22' );
146
+ await checkRequest (null , '' , expectContentType: false );
147
+ await checkRequest ({}, '' );
148
+ await checkRequest ({'x' : 3 }, 'x=3' );
149
+ await checkRequest ({'x' : 3 , 'y' : 4 }, 'x=3&y=4' );
150
+ await checkRequest ({'x' : null }, 'x=null' );
151
+ await checkRequest ({'x' : true }, 'x=true' );
152
+ await checkRequest ({'x' : 'foo' }, 'x=%22foo%22' );
153
+ await checkRequest ({'x' : [1 , 2 ]}, 'x=%5B1%2C2%5D' );
154
+ await checkRequest ({'x' : {'y' : 1 }}, 'x=%7B%22y%22%3A1%7D' );
155
+ await checkRequest ({'x' : RawParameter ('foo' )}, 'x=foo' );
156
+ await checkRequest ({'x' : RawParameter ('foo' ), 'y' : 'bar' }, 'x=foo&y=%22bar%22' );
157
157
});
158
158
159
159
test ('API success result' , () async {
@@ -176,13 +176,13 @@ void main() {
176
176
}
177
177
178
178
final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
179
- checkRequest (http.ClientException ('Oops' ), (it) => it
179
+ await checkRequest (http.ClientException ('Oops' ), (it) => it
180
180
..message.equals ('Oops' )
181
181
..asString.equals ('NetworkException: Oops (ClientException: Oops)' ));
182
- checkRequest (const TlsException ('Oops' ), (it) => it
182
+ await checkRequest (const TlsException ('Oops' ), (it) => it
183
183
..message.equals ('Oops' )
184
184
..asString.equals ('NetworkException: Oops (TlsException: Oops)' ));
185
- checkRequest ((foo: 'bar' ), (it) => it
185
+ await checkRequest ((foo: 'bar' ), (it) => it
186
186
..message.equals (zulipLocalizations.errorNetworkRequestFailed)
187
187
..asString.equals ('NetworkException: Network request failed ((foo: bar))' ));
188
188
});
@@ -233,17 +233,17 @@ void main() {
233
233
tryRequest (json: { 'result' : 'error' , 'code' : 'ERR' , 'msg' : 'Oops' }, httpStatus: 400 ),
234
234
).throws <ZulipApiException >();
235
235
236
- checkMalformed (json: {'result' : 'success' , 'code' : 'ERR' , 'msg' : 'Oops' });
237
- checkMalformed (json: {'result' : 'nonsense' , 'code' : 'ERR' , 'msg' : 'Oops' });
238
- checkMalformed (json: {/* result */ 'code' : 'ERR' , 'msg' : 'Oops' });
239
- checkMalformed (json: {'result' : 'error' , 'code' : 1 , 'msg' : 'Oops' });
240
- checkMalformed (json: {'result' : 'error' , 'code' : 'ERR' /* msg */ });
241
- checkMalformed (json: {'result' : 'error' , 'code' : 'ERR' , 'msg' : 1 });
242
- checkMalformed (json: {});
243
- checkMalformed (body: '' );
244
- checkMalformed (body: '<html><body><p>An error occurred</p></body></html>' );
245
- checkMalformed (json: {'result' : 'nonsense' }, httpStatus: 401 );
246
- checkMalformed (json: {'result' : 'nonsense' }, httpStatus: 499 );
236
+ await checkMalformed (json: {'result' : 'success' , 'code' : 'ERR' , 'msg' : 'Oops' });
237
+ await checkMalformed (json: {'result' : 'nonsense' , 'code' : 'ERR' , 'msg' : 'Oops' });
238
+ await checkMalformed (json: {/* result */ 'code' : 'ERR' , 'msg' : 'Oops' });
239
+ await checkMalformed (json: {'result' : 'error' , 'code' : 1 , 'msg' : 'Oops' });
240
+ await checkMalformed (json: {'result' : 'error' , 'code' : 'ERR' /* msg */ });
241
+ await checkMalformed (json: {'result' : 'error' , 'code' : 'ERR' , 'msg' : 1 });
242
+ await checkMalformed (json: {});
243
+ await checkMalformed (body: '' );
244
+ await checkMalformed (body: '<html><body><p>An error occurred</p></body></html>' );
245
+ await checkMalformed (json: {'result' : 'nonsense' }, httpStatus: 401 );
246
+ await checkMalformed (json: {'result' : 'nonsense' }, httpStatus: 499 );
247
247
});
248
248
249
249
test ('API 5xx errors' , () async {
0 commit comments