Skip to content

Commit 7465951

Browse files
gnpricechrisbobbe
authored andcommitted
test: Track update machines in TestGlobalStore
1 parent f0c76da commit 7465951

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

test/model/test_store.dart

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ import '../api/fake_api.dart';
1313
///
1414
/// The per-account stores will use [FakeApiConnection].
1515
///
16+
/// Unlike with [LiveGlobalStore] and the associated [UpdateMachine.load],
17+
/// there is no automatic event-polling loop or other automated requests.
18+
/// For each account loaded, there is a corresponding [UpdateMachine]
19+
/// in [updateMachines], which tests can use for invoking that logic
20+
/// explicitly when desired.
21+
///
1622
/// See also [TestZulipBinding.globalStore], which provides one of these.
1723
class TestGlobalStore extends GlobalStore {
1824
TestGlobalStore({required super.accounts});
1925

26+
/// A corresponding [UpdateMachine] for each loaded account.
27+
final Map<int, UpdateMachine> updateMachines = {};
28+
2029
final Map<int, InitialSnapshot> _initialSnapshots = {};
2130

2231
/// Add an account and corresponding server data to the test data.
@@ -50,12 +59,16 @@ class TestGlobalStore extends GlobalStore {
5059

5160
@override
5261
Future<PerAccountStore> loadPerAccount(Account account) {
53-
return Future.value(PerAccountStore.fromInitialSnapshot(
62+
final initialSnapshot = _initialSnapshots[account.id]!;
63+
final store = PerAccountStore.fromInitialSnapshot(
5464
globalStore: this,
5565
account: account,
5666
connection: FakeApiConnection.fromAccount(account),
57-
initialSnapshot: _initialSnapshots[account.id]!,
58-
));
67+
initialSnapshot: initialSnapshot,
68+
);
69+
updateMachines[account.id] = UpdateMachine.fromInitialSnapshot(
70+
store: store, initialSnapshot: initialSnapshot);
71+
return Future.value(store);
5972
}
6073
}
6174

0 commit comments

Comments
 (0)