pub struct FakeStores { /* private fields */ }Expand description
The in-memory stores, wrapped for turn tests.
Cheap to build and self-contained: one MemoryStores on a frozen
ManualClock, a CountingStores in front of it, and a Stores built
from the counting layer — which is the value the runtime takes.
Implementations§
Source§impl FakeStores
impl FakeStores
Sourcepub fn memory(&self) -> &Arc<MemoryStores> ⓘ
pub fn memory(&self) -> &Arc<MemoryStores> ⓘ
The underlying store, for the few things only it can do.
Sourcepub fn clock(&self) -> &Arc<ManualClock> ⓘ
pub fn clock(&self) -> &Arc<ManualClock> ⓘ
The clock the store stamps its own columns from.
Sourcepub fn fail_at(
&self,
point: FailurePoint,
error: StoreError,
) -> Result<(), StoreError>
pub fn fail_at( &self, point: FailurePoint, error: StoreError, ) -> Result<(), StoreError>
Arms one failure at point: the next call reaching it returns error.
Whether the write before the boundary survives is part of the point’s
meaning; see FailurePoint.
§Errors
Corruptwhen the store’s internal lock is poisoned.
Sourcepub fn fail_at_boundary(
&self,
name: &str,
error: StoreError,
) -> Result<(), UnknownBoundary>
pub fn fail_at_boundary( &self, name: &str, error: StoreError, ) -> Result<(), UnknownBoundary>
Arms one failure at the boundary with this name (see
CRASH_BOUNDARIES).
§Errors
UnknownBoundarywhen no boundary carries that name.
Sourcepub fn armed_failures(&self) -> Vec<FailurePoint>
pub fn armed_failures(&self) -> Vec<FailurePoint>
The boundaries still armed, in arming order.
Sourcepub fn clear_failures(&self)
pub fn clear_failures(&self)
Disarms every pending failure.
Sourcepub fn call_count(&self, method: &str) -> usize
pub fn call_count(&self, method: &str) -> usize
How many times method was called, as "<role>.<method>".
Sourcepub fn calls(&self) -> Vec<(&'static str, usize)>
pub fn calls(&self) -> Vec<(&'static str, usize)>
Every method called at least once, in key order.
Sourcepub fn total_calls(&self) -> usize
pub fn total_calls(&self) -> usize
Total calls across every store method.
Sourcepub fn reset_calls(&self)
pub fn reset_calls(&self)
Forgets the tally, keeping the data. Use it between the arrange and act phases of a test.
Sourcepub async fn events_for(
&self,
account: &AccountId,
case_key: &CaseKey,
) -> Result<Vec<StoredEvent>, StoreError>
pub async fn events_for( &self, account: &AccountId, case_key: &CaseKey, ) -> Result<Vec<StoredEvent>, StoreError>
Every event of a case, in append order.
§Errors
- Whatever the store returns;
NotFoundis never one of them, an unknown case simply has no events.
Sourcepub async fn event_types(
&self,
account: &AccountId,
case_key: &CaseKey,
) -> Result<Vec<String>, StoreError>
pub async fn event_types( &self, account: &AccountId, case_key: &CaseKey, ) -> Result<Vec<String>, StoreError>
The event types of a case, in append order: the shortest assertion about what a turn actually committed.
§Errors
- Whatever the store returns.
Sourcepub async fn events_by_ids(
&self,
account: &AccountId,
ids: &[EventId],
) -> Result<Vec<StoredEvent>, StoreError>
pub async fn events_by_ids( &self, account: &AccountId, ids: &[EventId], ) -> Result<Vec<StoredEvent>, StoreError>
The events with these identifiers, for checking a receipt’s citations.
§Errors
- Whatever the store returns.
Sourcepub async fn journal_entry(
&self,
account: &AccountId,
command_id: &CommandId,
) -> Result<CommandJournalEntry, StoreError>
pub async fn journal_entry( &self, account: &AccountId, command_id: &CommandId, ) -> Result<CommandJournalEntry, StoreError>
The journal entry of a command.
§Errors
NotFoundwhen the command was never admitted for this account.
Sourcepub async fn journal_for_turn(
&self,
account: &AccountId,
turn_id: &TurnId,
) -> Result<Vec<CommandJournalEntry>, StoreError>
pub async fn journal_for_turn( &self, account: &AccountId, turn_id: &TurnId, ) -> Result<Vec<CommandJournalEntry>, StoreError>
Sourcepub async fn open_interactions(
&self,
account: &AccountId,
case_key: &CaseKey,
) -> Result<Vec<Interaction>, StoreError>
pub async fn open_interactions( &self, account: &AccountId, case_key: &CaseKey, ) -> Result<Vec<Interaction>, StoreError>
Sourcepub async fn interaction(
&self,
account: &AccountId,
id: &InteractionId,
) -> Result<InteractionRecord, StoreError>
pub async fn interaction( &self, account: &AccountId, id: &InteractionId, ) -> Result<InteractionRecord, StoreError>
Sourcepub async fn turn(
&self,
account: &AccountId,
turn_id: &TurnId,
) -> Result<StoredTurn, StoreError>
pub async fn turn( &self, account: &AccountId, turn_id: &TurnId, ) -> Result<StoredTurn, StoreError>
A stored turn, user side and assistant side.
§Errors
NotFoundwhen the turn does not exist for this account.