test: Ensure isolation of user and node IDs between tests
This commit is contained in:
parent
a8726ef968
commit
62689b45d4
1 changed files with 22 additions and 5 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue