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 3', () {
      expect(db.schemaVersion, equals(3));
    });

    test('can be closed without error', () async {
      await db.close();
      // If we reach here, close succeeded. Re-create for tearDown.
      db = AppDatabase(NativeDatabase.memory());
    });
  });
}
