Gate auto sync with network reachability checks
This commit is contained in:
@@ -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}) {
|
||||
|
||||
Reference in New Issue
Block a user