mirror of
https://github.com/immich-app/immich.git
synced 2026-05-21 23:26:31 -04:00
refactor: yeet old timeline (#27666)
* refactor: yank old timeline # Conflicts: # mobile/lib/presentation/pages/editing/drift_edit.page.dart # mobile/lib/providers/websocket.provider.dart # mobile/lib/routing/router.dart * more cleanup * remove native code * chore: bump sqlite-data version * remove old background tasks from BGTaskSchedulerPermittedIdentifiers * rebase --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/exif.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
import '../../fixtures/exif.stub.dart';
|
||||
import '../../test_utils.dart';
|
||||
|
||||
Future<void> _populateExifTable(Isar db) async {
|
||||
await db.writeTxn(() async {
|
||||
await db.exifInfos.putAll([
|
||||
ExifInfo.fromDto(ExifStub.size),
|
||||
ExifInfo.fromDto(ExifStub.gps),
|
||||
ExifInfo.fromDto(ExifStub.rotated90CW),
|
||||
ExifInfo.fromDto(ExifStub.rotated270CW),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
void main() {
|
||||
late Isar db;
|
||||
late IsarExifRepository sut;
|
||||
|
||||
setUp(() async {
|
||||
db = await TestUtils.initIsar();
|
||||
sut = IsarExifRepository(db);
|
||||
});
|
||||
|
||||
group("Return with proper orientation", () {
|
||||
setUp(() async {
|
||||
await _populateExifTable(db);
|
||||
});
|
||||
|
||||
test("isFlipped true for 90CW", () async {
|
||||
final exif = await sut.get(ExifStub.rotated90CW.assetId!);
|
||||
expect(exif!.isFlipped, true);
|
||||
});
|
||||
|
||||
test("isFlipped true for 270CW", () async {
|
||||
final exif = await sut.get(ExifStub.rotated270CW.assetId!);
|
||||
expect(exif!.isFlipped, true);
|
||||
});
|
||||
|
||||
test("isFlipped false for the original non-rotated image", () async {
|
||||
final exif = await sut.get(ExifStub.size.assetId!);
|
||||
expect(exif!.isFlipped, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:drift/drift.dart' hide isNull;
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/store.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/store.entity.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/store.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
import '../../fixtures/user.stub.dart';
|
||||
import '../../test_utils.dart';
|
||||
|
||||
const _kTestAccessToken = "#TestToken";
|
||||
final _kTestBackupFailed = DateTime(2025, 2, 20, 11, 45);
|
||||
@@ -16,30 +17,54 @@ const _kTestVersion = 10;
|
||||
const _kTestColorfulInterface = false;
|
||||
final _kTestUser = UserStub.admin;
|
||||
|
||||
Future<void> _addIntStoreValue(Isar db, StoreKey key, int? value) async {
|
||||
await db.storeValues.put(StoreValue(key.id, intValue: value, strValue: null));
|
||||
}
|
||||
|
||||
Future<void> _addStrStoreValue(Isar db, StoreKey key, String? value) async {
|
||||
await db.storeValues.put(StoreValue(key.id, intValue: null, strValue: value));
|
||||
}
|
||||
|
||||
Future<void> _populateStore(Isar db) async {
|
||||
await db.writeTxn(() async {
|
||||
await _addIntStoreValue(db, StoreKey.colorfulInterface, _kTestColorfulInterface ? 1 : 0);
|
||||
await _addIntStoreValue(db, StoreKey.backupFailedSince, _kTestBackupFailed.millisecondsSinceEpoch);
|
||||
await _addStrStoreValue(db, StoreKey.accessToken, _kTestAccessToken);
|
||||
await _addIntStoreValue(db, StoreKey.version, _kTestVersion);
|
||||
Future<void> _populateStore(Drift db) async {
|
||||
await db.batch((batch) async {
|
||||
batch.insert(
|
||||
db.storeEntity,
|
||||
StoreEntityCompanion(
|
||||
id: Value(StoreKey.colorfulInterface.id),
|
||||
intValue: const Value(_kTestColorfulInterface ? 1 : 0),
|
||||
stringValue: const Value(null),
|
||||
),
|
||||
);
|
||||
batch.insert(
|
||||
db.storeEntity,
|
||||
StoreEntityCompanion(
|
||||
id: Value(StoreKey.backupFailedSince.id),
|
||||
intValue: Value(_kTestBackupFailed.millisecondsSinceEpoch),
|
||||
stringValue: const Value(null),
|
||||
),
|
||||
);
|
||||
batch.insert(
|
||||
db.storeEntity,
|
||||
StoreEntityCompanion(
|
||||
id: Value(StoreKey.accessToken.id),
|
||||
intValue: const Value(null),
|
||||
stringValue: const Value(_kTestAccessToken),
|
||||
),
|
||||
);
|
||||
batch.insert(
|
||||
db.storeEntity,
|
||||
StoreEntityCompanion(
|
||||
id: Value(StoreKey.version.id),
|
||||
intValue: const Value(_kTestVersion),
|
||||
stringValue: const Value(null),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void main() {
|
||||
late Isar db;
|
||||
late IsarStoreRepository sut;
|
||||
late Drift db;
|
||||
late DriftStoreRepository sut;
|
||||
|
||||
setUp(() async {
|
||||
db = await TestUtils.initIsar();
|
||||
sut = IsarStoreRepository(db);
|
||||
db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true));
|
||||
sut = DriftStoreRepository(db);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await db.close();
|
||||
});
|
||||
|
||||
group('Store Repository converters:', () {
|
||||
@@ -98,10 +123,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('deleteAll()', () async {
|
||||
final count = await db.storeValues.count();
|
||||
final count = await db.storeEntity.count().getSingle();
|
||||
expect(count, isNot(isZero));
|
||||
await sut.deleteAll();
|
||||
unawaited(expectLater(await db.storeValues.count(), isZero));
|
||||
unawaited(expectLater(await db.storeEntity.count().getSingle(), isZero));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:immich_mobile/domain/models/sync_event.model.dart';
|
||||
import 'package:immich_mobile/domain/services/store.service.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/store.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/sync_api.repository.dart';
|
||||
import 'package:immich_mobile/utils/semver.dart';
|
||||
@@ -13,7 +16,6 @@ import 'package:openapi/api.dart';
|
||||
|
||||
import '../../api.mocks.dart';
|
||||
import '../../service.mocks.dart';
|
||||
import '../../test_utils.dart';
|
||||
|
||||
class MockHttpClient extends Mock implements http.Client {}
|
||||
|
||||
@@ -38,7 +40,8 @@ void main() {
|
||||
late int testBatchSize = 3;
|
||||
|
||||
setUpAll(() async {
|
||||
await StoreService.init(storeRepository: IsarStoreRepository(await TestUtils.initIsar()));
|
||||
final db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true));
|
||||
await StoreService.init(storeRepository: DriftStoreRepository(db));
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
@@ -137,7 +140,7 @@ void main() {
|
||||
bool abortWasCalledInCallback = false;
|
||||
final Completer<void> firstBatchReceived = Completer<void>();
|
||||
|
||||
Future<void> onDataCallback(List<SyncEvent> events, Function() abort, Function() _) async {
|
||||
Future<void> onDataCallback(List<SyncEvent> _, Function() abort, Function() _) async {
|
||||
onDataCallCount++;
|
||||
if (onDataCallCount == 1) {
|
||||
abort();
|
||||
@@ -241,7 +244,7 @@ void main() {
|
||||
final streamError = Exception("Network Error");
|
||||
int onDataCallCount = 0;
|
||||
|
||||
Future<void> onDataCallback(List<SyncEvent> events, Function() _, Function() __) async {
|
||||
Future<void> onDataCallback(List<SyncEvent> _, Function() _, Function() __) async {
|
||||
onDataCallCount++;
|
||||
}
|
||||
|
||||
@@ -267,7 +270,7 @@ void main() {
|
||||
when(() => mockStreamedResponse.stream).thenAnswer((_) => http.ByteStream(errorBodyController.stream));
|
||||
|
||||
int onDataCallCount = 0;
|
||||
Future<void> onDataCallback(List<SyncEvent> events, Function() _, Function() __) async {
|
||||
Future<void> onDataCallback(List<SyncEvent> _, Function() _, Function() __) async {
|
||||
onDataCallCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:immich_mobile/infrastructure/repositories/backup.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/device_asset.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/local_album.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/local_asset.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/log.repository.dart';
|
||||
@@ -11,22 +10,15 @@ import 'package:immich_mobile/infrastructure/repositories/sync_api.repository.da
|
||||
import 'package:immich_mobile/infrastructure/repositories/sync_migration.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/trashed_local_asset.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/user.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/user_api.repository.dart';
|
||||
import 'package:immich_mobile/repositories/drift_album_api_repository.dart';
|
||||
import 'package:immich_mobile/repositories/upload.repository.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
class MockStoreRepository extends Mock implements IsarStoreRepository {}
|
||||
|
||||
class MockDriftStoreRepository extends Mock implements DriftStoreRepository {}
|
||||
|
||||
class MockLogRepository extends Mock implements LogRepository {}
|
||||
|
||||
class MockIsarUserRepository extends Mock implements IsarUserRepository {}
|
||||
|
||||
class MockDeviceAssetRepository extends Mock implements IsarDeviceAssetRepository {}
|
||||
|
||||
class MockSyncStreamRepository extends Mock implements SyncStreamRepository {}
|
||||
|
||||
class MockLocalAlbumRepository extends Mock implements DriftLocalAlbumRepository {}
|
||||
|
||||
Reference in New Issue
Block a user