feat: add Flutter mobile app
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:imagefind_mobile/src/offline_database.dart';
|
||||
|
||||
void main() {
|
||||
late OfflineDatabase database;
|
||||
|
||||
setUp(() => database = OfflineDatabase(NativeDatabase.memory()));
|
||||
tearDown(() => database.close());
|
||||
|
||||
test(
|
||||
'offline progress survives an upsert and can become completed',
|
||||
() async {
|
||||
await database.saveDownload(
|
||||
OfflineEntriesCompanion.insert(
|
||||
videoId: 'v1',
|
||||
title: '测试视频',
|
||||
localPath: 'video.mp4',
|
||||
partialPath: const Value('video.mp4.part'),
|
||||
bytesDownloaded: const Value(512),
|
||||
totalBytes: const Value(1024),
|
||||
status: const Value('downloading'),
|
||||
),
|
||||
);
|
||||
await database.saveDownload(
|
||||
OfflineEntriesCompanion.insert(
|
||||
videoId: 'v1',
|
||||
title: '测试视频',
|
||||
localPath: 'video.mp4',
|
||||
partialPath: const Value(null),
|
||||
bytesDownloaded: const Value(1024),
|
||||
totalBytes: const Value(1024),
|
||||
status: const Value('completed'),
|
||||
),
|
||||
);
|
||||
|
||||
final entry = await database.downloadFor('v1');
|
||||
expect(entry?.status, 'completed');
|
||||
expect(entry?.partialPath, null);
|
||||
expect(entry?.bytesDownloaded, 1024);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user