Gate auto sync with network reachability checks

This commit is contained in:
Rijad Zuzo
2026-02-15 23:31:34 +01:00
parent 54321e8b64
commit 04d269ae10
10 changed files with 145 additions and 2 deletions
@@ -68,6 +68,11 @@ void main() {
);
final Future<bool> first = controller.trigger();
for (int i = 0; i < 20 && !controller.isRunning; i += 1) {
await Future<void>.delayed(const Duration(milliseconds: 1));
}
expect(controller.isRunning, isTrue);
final bool second = await controller.trigger();
completer.complete();
final bool firstCompleted = await first;
@@ -76,6 +81,23 @@ void main() {
expect(second, isFalse);
expect(callCount, 1);
});
test('skips trigger when connectivity gate denies run', () async {
int callCount = 0;
final SyncAutoTriggerController controller = SyncAutoTriggerController(
syncNow: () async {
callCount += 1;
return _result(success: true);
},
now: DateTime.now,
canTrigger: () async => false,
minimumInterval: Duration.zero,
);
final bool executed = await controller.trigger();
expect(executed, isFalse);
expect(callCount, 0);
});
}
SyncRunResult _result({required bool success}) {