offline_cache_sync_test 0.1.0 copy "offline_cache_sync_test: ^0.1.0" to clipboard
offline_cache_sync_test: ^0.1.0 copied to clipboard

Test kit for offline_cache_sync: fake clock/scheduler/connectivity, a scripted fake server with idempotency, a crash-injecting store, and the LocalStore conformance suite every storage adapter must pass.

offline_cache_sync_test #

Test kit for offline_cache_sync.

  • FakeClock: a deterministic clock and scheduler. Retry timers fire in advance().
  • FakeConnectivity: flip online/offline from a test.
  • FakeServer: an in-memory REST-like backend. It has revisions and ETags, honours Idempotency-Key (replay, or a 422 on payload mismatch), detects conflicts, and can script failures (lostBeforeServer, lostAfterApply, unavailable, reject).
  • CrashingStore: kills the "process" before or after the commit of a chosen transaction.
  • EngineHarness: all of the above, wired together.
  • runLocalStoreConformance: the suite every LocalStore adapter must pass.
test('a lost response is not applied twice', () async {
  final h = await EngineHarness.create();
  h.server.seed('1', {'n': 0});
  await h.items.get('1');
  h.server.failNextSends(1, SendFailure.lostAfterApply);
  await h.items.mutate('1', const Increment('n', 1));
  for (var i = 0; i < 10 && h.storedOps.isNotEmpty; i++) {
    await h.advance(const Duration(minutes: 10));
  }
  expect(h.server.valueOf('1'), {'n': 1});
});
0
likes
140
points
50
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Test kit for offline_cache_sync: fake clock/scheduler/connectivity, a scripted fake server with idempotency, a crash-injecting store, and the LocalStore conformance suite every storage adapter must pass.

Repository (GitHub)
View/report issues

Topics

#offline-first #testing #sync

License

MIT (license)

Dependencies

offline_cache_sync, test

More

Packages that depend on offline_cache_sync_test