import 'package:drift/native.dart';
import 'package:scheduler_persistence_sqlite/sqlite.dart';
import 'package:test/test.dart';

void main() {
  test('opens schema version 1 with expected tables', () async {
    final db = SchedulerDb(NativeDatabase.memory());
    addTearDown(db.close);

    expect(db.schemaVersion, 1);

    final rows = await db
        .customSelect(
          "SELECT name FROM sqlite_master "
          "WHERE type = 'table' AND name NOT LIKE 'sqlite_%' "
          'ORDER BY name',
        )
        .get();
    final tableNames = rows.map((row) => row.data['name']).toList();

    expect(
      tableNames,
      containsAll(<String>[
        'locked_blocks',
        'locked_overrides',
        'projects',
        'settings',
        'snapshots',
        'tasks',
      ]),
    );
  });
}
