Files
umbrix/test/core/database/migrations_test.dart

43 lines
1.2 KiB
Dart
Raw Normal View History

2023-10-02 18:51:14 +03:30
import 'package:drift_dev/api/migrations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:umbrix/core/database/app_database.dart';
2023-10-02 18:51:14 +03:30
import 'generated_migrations/schema.dart';
void main() {
late SchemaVerifier verifier;
setUpAll(() {
verifier = SchemaVerifier(GeneratedHelper());
});
test('upgrade from v1 to v2', () async {
final connection = await verifier.startAt(1);
final db = AppDatabase(connection: connection);
await verifier.migrateAndValidate(db, 2);
2023-11-17 21:30:09 +03:30
await db.close();
});
test('upgrade from v2 to v3', () async {
final connection = await verifier.startAt(2);
final db = AppDatabase(connection: connection);
await verifier.migrateAndValidate(db, 3);
2024-07-04 21:33:00 +02:00
// final prePopulated = await db.select(db.geoAssetEntries).get();
2023-11-17 21:30:09 +03:30
await db.close();
2024-07-04 21:33:00 +02:00
// expect(prePopulated.length, equals(2));
2023-11-17 21:30:09 +03:30
});
test('upgrade from v1 to v3 with pre-population', () async {
final connection = await verifier.startAt(1);
final db = AppDatabase(connection: connection);
await verifier.migrateAndValidate(db, 3);
2024-07-04 21:33:00 +02:00
// final prePopulated = await db.select(db.geoAssetEntries).get();
2023-11-17 21:30:09 +03:30
await db.close();
2024-07-04 21:33:00 +02:00
// expect(prePopulated.length, equals(2));
2023-10-02 18:51:14 +03:30
});
}