Skip to content

Commit 10c0079

Browse files
committed
fix storage test
1 parent 40700c7 commit 10c0079

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

templates/flutter/test/services/service_test.dart.twig

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,23 @@ class MockClient extends Mock implements Client {
3131
) async {
3232
return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done');
3333
}
34+
35+
@override
36+
Future<Response> chunkedUpload({
37+
String? path,
38+
Map<String, dynamic>? params,
39+
String? paramName,
40+
String? idParamName,
41+
Map<String, String>? headers,
42+
Function(UploadProgress)? onProgress,
43+
}) async {
44+
return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {}));
45+
}
3446
}
3547

3648
void main() {
3749
group('{{service.name | caseUcfirst}} test', () {
38-
late Client client;
50+
late MockClient client;
3951
late {{service.name | caseUcfirst}} {{service.name | caseCamel}};
4052

4153
setUp(() {
@@ -65,14 +77,22 @@ void main() {
6577
when(client.webAuth(
6678
Uri(),
6779
)).thenAnswer((_) async => 'done');
80+
{%~ elseif 'multipart/form-data' in method.consumes ~%}
81+
when(client.chunkedUpload(
82+
path: argThat(isNotNull),
83+
params: argThat(isNotNull),
84+
paramName: argThat(isNotNull),
85+
idParamName: argThat(isNotNull),
86+
headers: argThat(isNotNull),
87+
)).thenAnswer((_) async => Response(data: data));
6888
{%~ else ~%}
6989
when(client.call(
7090
HttpMethod.{{method.method | caseLower}},
7191
)).thenAnswer((_) async => Response(data: data));
7292
{%~ endif ~%}
7393

7494
final response = await {{service.name | caseCamel}}.{{method.name | caseCamel}}({%~ for parameter in method.parameters.all | filter((param) => param.required) ~%}
75-
{{parameter.name | caseCamel}}: {% if parameter.type == 'object' %}{}{% else %}'{{parameter.example}}'{%~ endif ~%},{%~ endfor ~%}
95+
{{parameter.name | caseCamel}}: {% if parameter.type == 'object' %}{}{% elseif parameter.type == 'file' %}InputFile.fromPath(path: './image.png'){% else %}'{{parameter.example}}'{%~ endif ~%},{%~ endfor ~%}
7696
);
7797

7898
{%- if method.type == '___location' ~%}

0 commit comments

Comments
 (0)