Skip to content

Commit 874e3bf

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 795b46e commit 874e3bf

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,8 +124,7 @@ 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.
@@ -135,9 +134,6 @@ class TestGlobalStore extends GlobalStore with _ApiConnectionsMixin, _DatabaseMi
135134
required super.accounts,
136135
}) : super(globalSettings: globalSettings ?? eg.globalSettings());
137136

138-
/// A corresponding [UpdateMachine] for each loaded account.
139-
final Map<int, UpdateMachine> updateMachines = {};
140-
141137
final Map<int, InitialSnapshot> _initialSnapshots = {};
142138

143139
static const Duration removeAccountDuration = Duration(milliseconds: 1);
@@ -174,7 +170,7 @@ class TestGlobalStore extends GlobalStore with _ApiConnectionsMixin, _DatabaseMi
174170
accountId: accountId,
175171
initialSnapshot: initialSnapshot,
176172
);
177-
updateMachines[accountId] = UpdateMachine.fromInitialSnapshot(
173+
UpdateMachine.fromInitialSnapshot(
178174
store: store, initialSnapshot: initialSnapshot);
179175
return Future.value(store);
180176
}

0 commit comments

Comments
 (0)