Skip to main content

FakeStores

Struct FakeStores 

Source
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

Source

pub fn new() -> Self

Empty stores on a clock frozen at the Unix epoch.

Source

pub fn at(start: DateTime<Utc>) -> Self

Empty stores on a clock frozen at start.

Source

pub fn stores(&self) -> &Stores

The set of stores to hand to the code under test.

Source

pub fn memory(&self) -> &Arc<MemoryStores> ⓘ

The underlying store, for the few things only it can do.

Source

pub fn clock(&self) -> &Arc<ManualClock> ⓘ

The clock the store stamps its own columns from.

Source

pub fn now(&self) -> DateTime<Utc>

The instant the store would stamp a write with right now.

Source

pub fn advance(&self, delta: TimeDelta)

Moves the clock forward.

Source

pub fn set_time(&self, instant: DateTime<Utc>)

Moves the clock to instant.

Source

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
  • Corrupt when the store’s internal lock is poisoned.
Source

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
Source

pub fn armed_failures(&self) -> Vec<FailurePoint>

The boundaries still armed, in arming order.

Source

pub fn clear_failures(&self)

Disarms every pending failure.

Source

pub fn call_count(&self, method: &str) -> usize

How many times method was called, as "<role>.<method>".

Source

pub fn calls(&self) -> Vec<(&'static str, usize)>

Every method called at least once, in key order.

Source

pub fn total_calls(&self) -> usize

Total calls across every store method.

Source

pub fn reset_calls(&self)

Forgets the tally, keeping the data. Use it between the arrange and act phases of a test.

Source

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; NotFound is never one of them, an unknown case simply has no events.
Source

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.
Source

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.
Source

pub async fn journal_entry( &self, account: &AccountId, command_id: &CommandId, ) -> Result<CommandJournalEntry, StoreError>

The journal entry of a command.

§Errors
  • NotFound when the command was never admitted for this account.
Source

pub async fn journal_for_turn( &self, account: &AccountId, turn_id: &TurnId, ) -> Result<Vec<CommandJournalEntry>, StoreError>

Every journal entry of a turn, in admission order.

§Errors
  • Whatever the store returns.
Source

pub async fn open_interactions( &self, account: &AccountId, case_key: &CaseKey, ) -> Result<Vec<Interaction>, StoreError>

The open cards of a case.

§Errors
  • Whatever the store returns.
Source

pub async fn interaction( &self, account: &AccountId, id: &InteractionId, ) -> Result<InteractionRecord, StoreError>

One card, whatever its status.

§Errors
  • NotFound when it does not exist for this account.
Source

pub async fn turn( &self, account: &AccountId, turn_id: &TurnId, ) -> Result<StoredTurn, StoreError>

A stored turn, user side and assistant side.

§Errors
  • NotFound when the turn does not exist for this account.
Source

pub async fn turn_phase( &self, account: &AccountId, turn_id: &TurnId, ) -> Result<TurnPhaseMarker, StoreError>

The phase marker of a turn.

§Errors
  • NotFound when the turn does not exist for this account.
Source

pub async fn replay_record( &self, account: &AccountId, turn_id: &TurnId, ) -> Result<ReplayRecord, StoreError>

The replay record of a turn.

§Errors
  • NotFound when no record was written for this account and turn.
Source

pub async fn outbox_for_command( &self, command_id: &CommandId, ) -> Result<Vec<OutboxRecord>, StoreError>

The outbox rows a command produced.

§Errors
  • Whatever the store returns.
Source

pub async fn replay_records_for( &self, account: &AccountId, conversation: &ConversationId, limit: usize, ) -> Result<Vec<ReplayRecord>, StoreError>

Every conversation-scoped replay record, most recent first.

§Errors
  • Whatever the store returns.

Trait Implementations§

Source§

impl Debug for FakeStores

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FakeStores

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more