chore: Move the drift_offline_first to legacy in favor of Serverpod implementation (#32)

This commit is contained in:
Marcelo Mendonça Soares 2026-04-05 23:20:21 -03:00 • committed by Marcelo Soares
commit cbc472523b
No known key found for this signature in database
GPG key ID: CB2F09CE66E99EAD

View file

@ -0,0 +1,35 @@
import 'package:drift_offline_sync/src/database/triggers.dart';
import 'package:test/test.dart';
import '../utils/database.dart';
void main() {
group('Given a database with an OfflineSyncMigrator', () {
group('when running the migration', () {
setUp(() async {
// Insert a new row to trigger the migration.
await database.managers.todosTable.create(
(t) => t(content: 'test'),
);
});
test('then the triggers are created for every synchronized table.', () async {
final allTriggerNames = await database.getCrdtTriggers();
for (final table in database.createMigrator().synchronizedTables) {
final triggerNames = allTriggerNames
.where((name) => name.startsWith('__crdt__${table.actualTableName}__'))
.toList();
expect(triggerNames, contains('__crdt__${table.actualTableName}__insert'));
expect(triggerNames, contains('__crdt__${table.actualTableName}__update'));
expect(triggerNames, contains('__crdt__${table.actualTableName}__delete'));
}
});
});
});
// TODO: Add a test for the case where a table has no primary key.
// TODO: Add a test for the case where a table has multiple primary key columns.
// TODO: Add a test for the case where a table has only primary key columns.
}