- Add Rooms, Tasks, TaskCompletions Drift tables with schema v2 migration - Create RoomsDao with CRUD, watchAll, watchWithStats, cascade delete, reorder - Create TasksDao with CRUD, watchInRoom (sorted by due), completeTask, overdue detection - Implement calculateNextDueDate and catchUpToPresent pure scheduling functions - Define IntervalType enum (8 types), EffortLevel enum, FrequencyInterval model - Add formatRelativeDate German formatter and curatedRoomIcons icon list - Enable PRAGMA foreign_keys in beforeOpen migration strategy - All 30 unit tests passing (17 scheduling + 6 rooms DAO + 7 tasks DAO) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
742 B
Dart
32 lines
742 B
Dart
import 'package:drift/native.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:household_keeper/core/database/database.dart';
|
|
|
|
void main() {
|
|
group('AppDatabase', () {
|
|
late AppDatabase db;
|
|
|
|
setUp(() {
|
|
db = AppDatabase(NativeDatabase.memory());
|
|
});
|
|
|
|
tearDown(() async {
|
|
await db.close();
|
|
});
|
|
|
|
test('opens successfully with in-memory executor', () {
|
|
expect(db, isNotNull);
|
|
});
|
|
|
|
test('has schemaVersion 2', () {
|
|
expect(db.schemaVersion, equals(2));
|
|
});
|
|
|
|
test('can be closed without error', () async {
|
|
await db.close();
|
|
// If we reach here, close succeeded. Re-create for tearDown.
|
|
db = AppDatabase(NativeDatabase.memory());
|
|
});
|
|
});
|
|
}
|