test: Ensure isolation of user and node IDs between tests

This commit is contained in:
Marcelo Soares 2026-01-22 00:13:24 -03:00
commit 62689b45d4
No known key found for this signature in database
GPG key ID: CB2F09CE66E99EAD

View file

@ -72,8 +72,8 @@ class TodoDb extends _$TodoDb {
@override @override
OfflineSyncMigrator createMigrator() => OfflineSyncMigrator( OfflineSyncMigrator createMigrator() => OfflineSyncMigrator(
this, this,
userId: _userId, userId: testUserId,
nodeId: _nodeId, nodeId: testNodeId,
synchronizedTables: [ synchronizedTables: [
todosTable, todosTable,
categories, categories,
@ -110,6 +110,23 @@ class SomeDao extends DatabaseAccessor<TodoDb> with _$SomeDaoMixin {
SomeDao(super.attachedDatabase); SomeDao(super.attachedDatabase);
} }
// NOTE: Generated once so that the tests are deterministic. // NOTE: Generated once per test so that the tests are deterministic, but also
final _nodeId = const Uuid().v7(); // isolated between each other.
final _userId = const Uuid().v7(); String get testNodeId {
_testNodeId ??= const Uuid().v7();
addTearDown(() {
_testNodeId = null;
});
return _testNodeId!;
}
String get testUserId {
_testUserId ??= const Uuid().v7();
addTearDown(() {
_testUserId = null;
});
return _testUserId!;
}
String? _testNodeId;
String? _testUserId;