refactor(mobile): album api repository for album service ()

* refactor(mobile): album api repository for album service
This commit is contained in:
Fynn Petersen-Frey 2024-09-20 15:32:37 +02:00 committed by GitHub
commit 3868736799
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 751 additions and 223 deletions
mobile/test/modules/shared

View file

@ -39,8 +39,10 @@ void main() {
group('Test SyncService grouped', () {
late final Isar db;
final MockHashService hs = MockHashService();
final MockEntityService entityService = MockEntityService();
final MockAlbumMediaRepository albumMediaRepository =
MockAlbumMediaRepository();
final MockAlbumApiRepository albumApiRepository = MockAlbumApiRepository();
final owner = User(
id: "1",
updatedAt: DateTime.now(),
@ -48,6 +50,7 @@ void main() {
name: "first last",
isAdmin: false,
);
late SyncService s;
setUpAll(() async {
WidgetsFlutterBinding.ensureInitialized();
db = await TestUtils.initIsar();
@ -68,9 +71,15 @@ void main() {
db.assets.clearSync();
db.assets.putAllSync(initialAssets);
});
s = SyncService(
db,
hs,
entityService,
albumMediaRepository,
albumApiRepository,
);
});
test('test inserting existing assets', () async {
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> remoteAssets = [
makeAsset(checksum: "a", remoteId: "0-1"),
makeAsset(checksum: "b", remoteId: "2-1"),
@ -88,7 +97,6 @@ void main() {
});
test('test inserting new assets', () async {
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> remoteAssets = [
makeAsset(checksum: "a", remoteId: "0-1"),
makeAsset(checksum: "b", remoteId: "2-1"),
@ -109,7 +117,6 @@ void main() {
});
test('test syncing duplicate assets', () async {
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> remoteAssets = [
makeAsset(checksum: "a", remoteId: "0-1"),
makeAsset(checksum: "b", remoteId: "1-1"),
@ -157,7 +164,6 @@ void main() {
});
test('test efficient sync', () async {
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> toUpsert = [
makeAsset(checksum: "a", remoteId: "0-1"), // changed
makeAsset(checksum: "f", remoteId: "0-2"), // new