Expand description
Fake stores: the in-memory persistence layer with the three things a runtime test always ends up needing (spec §27.4, §27.7).
turnframe-store already ships the deterministic implementation and the
conformance suite that proves an adapter right. What it does not ship is the
ergonomics of driving it from a turn test, and those are the same three
every time:
- crash where I say. Recovery code is never exercised by the happy path,
so
FakeStores::fail_atarms a failure at one of the boundaries of spec §27.7, andcrash_boundarylooks one up by name so a table-driven chaos test can walk all seven. - count what was called. “The turn wrote the journal once” and “the
recovery path did not re-append the events” are assertions about call
counts, not about state. Every trait method is tallied as
"<role>.<method>". - stop the clock. Expiry, claim staleness and phase markers are timestamps the store stamps itself; a frozen clock turns “the card expired” into something the test makes true instead of waits for.
And then: assert what was persisted. The accessors on FakeStores
read through the underlying store without counting, so checking the
outcome of a turn never pollutes the tally the same test is asserting on.
§The suite comes with it
conformance is the store crate’s own suite, re-exported so an adopter
building a store over their own database reaches fixtures, doubles and the
contract through this one crate.
use turnframe_core::ids::{AccountId, ConversationId};
use turnframe_store::conversation::{ConversationRecord, ConversationStore};
use turnframe_test::stores::FakeStores;
let fake = FakeStores::new();
let account = AccountId::from("aurora");
let conversation = ConversationId::nil();
fake.stores()
.conversations()
.create_conversation(ConversationRecord::new(conversation, account.clone(), fake.now()))
.await?;
assert_eq!(fake.call_count("conversations.create_conversation"), 1);Modules§
- conformance
- An executable statement of the persistence contract.
Structs§
- Counting
Stores - Every persistence trait, counted and delegated to one
MemoryStores. - Fake
Stores - The in-memory stores, wrapped for turn tests.
- Manual
Clock - A clock that only moves when a test moves it.
- Memory
Stores - A complete, deterministic set of stores backed by one in-process state.
- Store
Call Counter - How many times each store method was called.
- Stores
- A complete set of stores.
- System
Clock - The wall clock.
- Unknown
Boundary - A name that is not one of the
CRASH_BOUNDARIES.
Enums§
- Failure
Point - A boundary at which the in-memory store can be made to fail (spec §27.7).
Constants§
- CRASH_
BOUNDARIES - The crash boundaries of spec §27.7, by name.
- MAX_
LISTED_ EVENTS - How many events
FakeStores::events_forreads at most. High enough that a test never has to think about it, low enough to stay a bounded read.
Traits§
- Clock
- Source of the current time for a store.
Functions§
- boundary_
name - The name of a boundary, or
"unknown"for one added after this table. - crash_
boundary - The boundary with this name, or
None.