refactor(mobile): encapsulate most access to photomanager in repository ()

* refactor(mobile): encapsulate most access to photomanager in repository
This commit is contained in:
Fynn Petersen-Frey 2024-09-18 17:15:52 +02:00 committed by GitHub
parent 6740c67ed8
commit 6995cc2b38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 1205 additions and 500 deletions
mobile/test/modules/shared

View file

@ -7,8 +7,9 @@ import 'package:immich_mobile/services/immich_logger.service.dart';
import 'package:immich_mobile/services/sync.service.dart';
import 'package:isar/isar.dart';
import '../../repository.mocks.dart';
import '../../service.mocks.dart';
import '../../test_utils.dart';
import 'shared_mocks.dart';
void main() {
Asset makeAsset({
@ -38,6 +39,8 @@ void main() {
group('Test SyncService grouped', () {
late final Isar db;
final MockHashService hs = MockHashService();
final MockAlbumMediaRepository albumMediaRepository =
MockAlbumMediaRepository();
final owner = User(
id: "1",
updatedAt: DateTime.now(),
@ -67,7 +70,7 @@ void main() {
});
});
test('test inserting existing assets', () async {
SyncService s = SyncService(db, hs);
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> remoteAssets = [
makeAsset(checksum: "a", remoteId: "0-1"),
makeAsset(checksum: "b", remoteId: "2-1"),
@ -85,7 +88,7 @@ void main() {
});
test('test inserting new assets', () async {
SyncService s = SyncService(db, hs);
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> remoteAssets = [
makeAsset(checksum: "a", remoteId: "0-1"),
makeAsset(checksum: "b", remoteId: "2-1"),
@ -106,7 +109,7 @@ void main() {
});
test('test syncing duplicate assets', () async {
SyncService s = SyncService(db, hs);
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> remoteAssets = [
makeAsset(checksum: "a", remoteId: "0-1"),
makeAsset(checksum: "b", remoteId: "1-1"),
@ -154,7 +157,7 @@ void main() {
});
test('test efficient sync', () async {
SyncService s = SyncService(db, hs);
SyncService s = SyncService(db, hs, albumMediaRepository);
final List<Asset> toUpsert = [
makeAsset(checksum: "a", remoteId: "0-1"), // changed
makeAsset(checksum: "f", remoteId: "0-2"), // new