@@ -31,11 +31,23 @@ class MockClient extends Mock implements Client {
31
31
) async {
32
32
return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done');
33
33
}
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
+ }
34
46
}
35
47
36
48
void main() {
37
49
group('{{service .name | caseUcfirst }} test', () {
38
- late Client client;
50
+ late MockClient client;
39
51
late {{service .name | caseUcfirst }} {{service .name | caseCamel }};
40
52
41
53
setUp(() {
@@ -65,14 +77,22 @@ void main() {
65
77
when(client.webAuth(
66
78
Uri(),
67
79
)).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));
68
88
{%~ else ~%}
69
89
when(client.call(
70
90
HttpMethod.{{method .method | caseLower }},
71
91
)).thenAnswer((_) async => Response(data: data));
72
92
{%~ endif ~%}
73
93
74
94
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 ~%}
76
96
);
77
97
78
98
{%- if method .type == ' ___location' ~%}
0 commit comments