Skip to content

Commit 52d4d92

Browse files
gnpricechrisbobbe
authored andcommitted
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 07fc56b commit 52d4d92

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
@@ -590,14 +590,13 @@ void main() {
590590

591591
group('UpdateMachine.poll', () {
592592
late TestGlobalStore globalStore;
593-
late UpdateMachine updateMachine;
594593
late PerAccountStore store;
594+
late UpdateMachine updateMachine;
595595
late FakeApiConnection connection;
596596

597597
void updateFromGlobalStore() {
598-
updateMachine = globalStore.updateMachines[eg.selfAccount.id]!;
599-
store = updateMachine.store;
600-
assert(identical(store, globalStore.perAccountSync(eg.selfAccount.id)));
598+
store = globalStore.perAccountSync(eg.selfAccount.id)!;
599+
updateMachine = store.updateMachine!;
601600
connection = store.connection as FakeApiConnection;
602601
}
603602

@@ -1005,9 +1004,8 @@ void main() {
10051004
completers().single.complete(store);
10061005
await future;
10071006
completers().clear();
1008-
final updateMachine = globalStore.updateMachines[eg.selfAccount.id] =
1009-
UpdateMachine.fromInitialSnapshot(
1010-
store: store, initialSnapshot: eg.initialSnapshot());
1007+
final updateMachine = UpdateMachine.fromInitialSnapshot(
1008+
store: store, initialSnapshot: eg.initialSnapshot());
10111009
updateMachine.debugPauseLoop();
10121010
updateMachine.poll();
10131011

test/model/test_store.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,13 @@ mixin _DatabaseMixin on GlobalStore {
124124
///
125125
/// Unlike with [LiveGlobalStore] and the associated [UpdateMachine.load],
126126
/// there is no automatic event-polling loop or other automated requests.
127-
/// For each account loaded, there is a corresponding [UpdateMachine]
128-
/// in [updateMachines], which tests can use for invoking that logic
127+
/// Tests can use [PerAccountStore.updateMachine] in order to invoke that logic
129128
/// explicitly when desired.
130129
///
131130
/// See also [TestZulipBinding.globalStore], which provides one of these.
132131
class TestGlobalStore extends GlobalStore with _ApiConnectionsMixin, _DatabaseMixin {
133132
TestGlobalStore({required super.globalSettings, required super.accounts});
134133

135-
/// A corresponding [UpdateMachine] for each loaded account.
136-
final Map<int, UpdateMachine> updateMachines = {};
137-
138134
final Map<int, InitialSnapshot> _initialSnapshots = {};
139135

140136
static const Duration removeAccountDuration = Duration(milliseconds: 1);
@@ -171,7 +167,7 @@ class TestGlobalStore extends GlobalStore with _ApiConnectionsMixin, _DatabaseMi
171167
accountId: accountId,
172168
initialSnapshot: initialSnapshot,
173169
);
174-
updateMachines[accountId] = UpdateMachine.fromInitialSnapshot(
170+
UpdateMachine.fromInitialSnapshot(
175171
store: store, initialSnapshot: initialSnapshot);
176172
return Future.value(store);
177173
}

0 commit comments

Comments
 (0)