chore: Move the drift_offline_first to legacy in favor of Serverpod implementation (#32)
This commit is contained in:
parent
027aec5ed0
commit
cbc472523b
1 changed files with 13575 additions and 284 deletions
27
legacy/drift_offline_sync/test/crdt/crdt_test_utils.dart
Normal file
27
legacy/drift_offline_sync/test/crdt/crdt_test_utils.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:drift_offline_sync/drift_offline_sync.dart';
|
||||
|
||||
extension CrdtDataEntryListExtensions on List<CrdtDataEntry> {
|
||||
CrdtDataEntry removeEntry(String columnName) {
|
||||
final entry = firstWhere((e) => e.columnName == columnName);
|
||||
remove(entry);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test helpers for CRDT tests.
|
||||
///
|
||||
/// Use [sortedEntries] when comparing [CrdtDataEntry] lists, since entry order
|
||||
/// is not guaranteed by the API or database.
|
||||
extension CrdtDataEntryTestExtensions on Iterable<CrdtDataEntry> {
|
||||
/// Returns a list of entries sorted by (tblName, rowId, columnName) for
|
||||
/// order-independent comparison in tests.
|
||||
List<CrdtDataEntry> get sortedEntries {
|
||||
return toList()..sort((a, b) {
|
||||
final c = a.tblName.compareTo(b.tblName);
|
||||
if (c != 0) return c;
|
||||
final r = a.rowId.compareTo(b.rowId);
|
||||
if (r != 0) return r;
|
||||
return a.columnName.compareTo(b.columnName);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue