mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-08 09:30:27 +00:00
feat(tasks): group extension folder downloads (#1594)
This commit is contained in:
1 parent
fc0a1e0ef9
commit
1e36599d52
84 files changed
+6690
-881
No files matched your search
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gopeed/api/api.dart' as api;
|
||||
import 'package:gopeed/api/model/create_task.dart';
|
||||
import 'package:gopeed/api/model/create_task_batch.dart';
|
||||
import 'package:gopeed/api/model/options.dart';
|
||||
import 'package:gopeed/api/model/patch_task.dart';
|
||||
import 'package:gopeed/api/model/request.dart';
|
||||
@@ -39,6 +40,32 @@ void main() {
|
||||
expect((createBody['opts'] as Map<String, dynamic>)['selectFiles'], [1]);
|
||||
});
|
||||
|
||||
test('batch sends rid and options and decodes the unified response in both modes', () async {
|
||||
for (final grouped in [false, true]) {
|
||||
final transport = _RecordingTransport();
|
||||
api.setTransportForTesting(transport);
|
||||
final result = await api.createTaskBatch(
|
||||
CreateTaskBatch(
|
||||
group: grouped,
|
||||
groupName: grouped ? 'folder' : '',
|
||||
reqs: [
|
||||
CreateTaskBatchItem(
|
||||
rid: 'resolved-id',
|
||||
opts: Options(selectFiles: [1]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
expect(result.taskIds, ['created-id']);
|
||||
expect(result.parentId, grouped ? 'parent' : null);
|
||||
final body = transport.data as Map<String, dynamic>;
|
||||
final member = (body['reqs'] as List).single as Map<String, dynamic>;
|
||||
expect(member['rid'], 'resolved-id');
|
||||
expect((member['opts'] as Map)['selectFiles'], [1]);
|
||||
expect(body, isNot(contains('groupId')));
|
||||
}
|
||||
});
|
||||
|
||||
test('patch preserves options in its independent request model', () async {
|
||||
final transport = _RecordingTransport();
|
||||
api.setTransportForTesting(transport);
|
||||
@@ -59,6 +86,15 @@ class _RecordingTransport implements GopeedTransport {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
this.data = jsonDecode(jsonEncode(data));
|
||||
if (path == 'api/v1/tasks/batch') {
|
||||
return {
|
||||
'code': 0,
|
||||
'data': {
|
||||
'taskIds': ['created-id'],
|
||||
if (this.data['group'] == true) 'parentId': 'parent',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (path == 'api/v1/tasks') {
|
||||
return {'code': 0, 'data': 'created-id'};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user