perf(library): stream scans and optimize queue queries

This commit is contained in:
zarzet
2026-08-18 11:03:05 +07:00
parent 29609b6084
commit 7fc27e8314
28 changed files with 2145 additions and 338 deletions
+10
View File
@@ -22,6 +22,16 @@ DownloadHistoryItem _historyItem({
void main() {
group('download history identity', () {
test('serializes download timestamps with an explicit UTC offset', () {
final item = _historyItem(
id: 'utc',
filePath: '/music/Album/Same Song.flac',
downloadedAt: DateTime(2026, 7, 22, 12, 30),
);
expect(item.toJson()['downloadedAt'], endsWith('Z'));
});
test('same track metadata does not merge files from different albums', () {
final first = _historyItem(
id: 'first',
+21
View File
@@ -167,4 +167,25 @@ void main() {
expect(results.single['status'], 'found');
expect(results.single['relative_dir'], 'Artist/Album');
});
test('iOS bookmark access releases the matching native lease', () async {
final calls = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(backendChannel, (call) async {
calls.add(call);
if (call.method == 'startAccessingIosBookmark') {
return {'path': '/music', 'token': 'lease-1'};
}
if (call.method == 'stopAccessingIosBookmark') return null;
fail('Unexpected method: ${call.method}');
});
final access = await PlatformBridge.startAccessingIosBookmark('bookmark');
expect(access?.path, '/music');
expect(access?.token, 'lease-1');
await PlatformBridge.stopAccessingIosBookmark(access!);
expect(calls[1].method, 'stopAccessingIosBookmark');
expect(calls[1].arguments, {'token': 'lease-1'});
});
}