Skip to content

Commit dd9b29b

Browse files
committed
test [nfc]: Simplify out TestGlobalStore.updateMachines
Thanks to the introduction of PerAccountStore.updateMachine in be6698e, this feature in the test code is no longer needed.
1 parent 1c7a2f8 commit dd9b29b

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

test/model/store_test.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,13 @@ void main() {
563563

564564
group('UpdateMachine.poll', () {
565565
late TestGlobalStore globalStore;
566-
late UpdateMachine updateMachine;
567566
late PerAccountStore store;
567+
late UpdateMachine updateMachine;
568568
late FakeApiConnection connection;
569569

570570
void updateFromGlobalStore() {
571-
updateMachine = globalStore.updateMachines[eg.selfAccount.id]!;
572-
store = updateMachine.store;
573-
assert(identical(store, globalStore.perAccountSync(eg.selfAccount.id)));
571+
store = globalStore.perAccountSync(eg.selfAccount.id)!;
572+
updateMachine = store.updateMachine!;
574573
connection = store.connection as FakeApiConnection;
575574
}
576575

@@ -978,9 +977,8 @@ void main() {
978977
completers().single.complete(store);
979978
await future;
980979
completers().clear();
981-
final updateMachine = globalStore.updateMachines[eg.selfAccount.id] =
982-
UpdateMachine.fromInitialSnapshot(
983-
store: store, initialSnapshot: eg.initialSnapshot());
980+
final updateMachine = UpdateMachine.fromInitialSnapshot(
981+
store: store, initialSnapshot: eg.initialSnapshot());
984982
updateMachine.debugPauseLoop();
985983
updateMachine.poll();
986984

test/model/test_store.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,13 @@ mixin _DatabaseMixin on GlobalStore {
118118
///
119119
/// Unlike with [LiveGlobalStore] and the associated [UpdateMachine.load],
120120
/// there is no automatic event-polling loop or other automated requests.
121-
/// For each account loaded, there is a corresponding [UpdateMachine]
122-
/// in [updateMachines], which tests can use for invoking that logic
121+
/// Tests can use [PerAccountStore.updateMachine] in order to invoke that logic
123122
/// explicitly when desired.
124123
///
125124
/// See also [TestZulipBinding.globalStore], which provides one of these.
126125
class TestGlobalStore extends GlobalStore with _ApiConnectionsMixin, _DatabaseMixin {
127126
TestGlobalStore({required super.accounts});
128127

129-
/// A corresponding [UpdateMachine] for each loaded account.
130-
final Map<int, UpdateMachine> updateMachines = {};
131-
132128
final Map<int, InitialSnapshot> _initialSnapshots = {};
133129

134130
static const Duration removeAccountDuration = Duration(milliseconds: 1);
@@ -165,7 +161,7 @@ class TestGlobalStore extends GlobalStore with _ApiConnectionsMixin, _DatabaseMi
165161
accountId: accountId,
166162
initialSnapshot: initialSnapshot,
167163
);
168-
updateMachines[accountId] = UpdateMachine.fromInitialSnapshot(
164+
UpdateMachine.fromInitialSnapshot(
169165
store: store, initialSnapshot: initialSnapshot);
170166
return Future.value(store);
171167
}

0 commit comments

Comments
 (0)