Skip to content

test: add proptest coverage for EntityEvents and idempotency_guard#130

Draft
nicolasburtey wants to merge 1 commit into
mainfrom
nb/proptest-events-and-idempotency
Draft

test: add proptest coverage for EntityEvents and idempotency_guard#130
nicolasburtey wants to merge 1 commit into
mainfrom
nb/proptest-events-and-idempotency

Conversation

@nicolasburtey
Copy link
Copy Markdown
Member

Summary

Adds two property-based test files covering the framework's core contracts.

tests/proptest_events.rs — invariants on EntityEvents:

  • mark_persisted_sequencing — across arbitrary push/extend/mark interleavings, persisted events have contiguous monotonic sequences from 1 and the new-events buffer is drained.
  • load_first_roundtrip — events serialized through GenericEvent and reloaded compare equal in order.
  • load_n_grouping — K entities × M events each: returned count = min(K, n), more flag matches, no event lost or stitched across ids.
  • iter_all_ordering — invariant after every step: iter_all yields exactly the cumulative push order regardless of when marks occur.

tests/proptest_idempotency.rs — the idempotency_guard! macro contract:

  • stutter_is_idempotentc; cc for any command, both already_applied-only and resets_on forms.
  • full_retry_is_noop_for_pure_commands — replaying any sequence of already_applied-only commands pushes zero new events. The retry-safety property callers depend on.
  • pure_commands_dedup_by_first_occurrence — extensional pin: stream equals deduplicated first-occurrence subsequence of pushed events.
  • resets_on_allows_alternation — Activate/Deactivate alternations never produce two consecutive identical states (proves resets_on actually resets the scan window).

Each property runs 4096 cases. Total runtime ~0.22s in release. No production code touched.

Test plan

  • cargo test --test proptest_events --test proptest_idempotency --release passes locally
  • CI green

Adds two property-based test files exercising the framework's core
contracts:

- tests/proptest_events.rs covers EntityEvents invariants:
  mark_new_events_persisted_at sequencing, load_first / load_n JSON
  roundtrip, load_n grouping across multiple entity ids, and iter_all
  ordering across arbitrary push/extend/mark interleavings.

- tests/proptest_idempotency.rs covers the idempotency_guard! macro:
  stutter idempotency for both already_applied and resets_on forms,
  full-retry safety for already_applied-only command sequences,
  extensional dedup-by-first-occurrence, and resets_on alternation.

Each property runs 4096 cases. Total runtime ~0.22s release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant