pub struct TestWorkflowContext {
pub run_id: Uuid,
pub workflow_name: String,
pub started_at: DateTime<Utc>,
pub auth: AuthContext,
/* private fields */
}Expand description
Test context for workflow functions.
Fields§
§run_id: Uuid§workflow_name: String§started_at: DateTime<Utc>§auth: AuthContextImplementations§
Source§impl TestWorkflowContext
impl TestWorkflowContext
Sourcepub fn builder(workflow_name: impl Into<String>) -> TestWorkflowContextBuilder
pub fn builder(workflow_name: impl Into<String>) -> TestWorkflowContextBuilder
Create a new builder.
Sourcepub fn is_resumed(&self) -> bool
pub fn is_resumed(&self) -> bool
Check if this is a resumed execution.
Sourcepub fn workflow_time(&self) -> DateTime<Utc>
pub fn workflow_time(&self) -> DateTime<Utc>
Get the deterministic workflow time.
Sourcepub fn is_step_completed(&self, name: &str) -> bool
pub fn is_step_completed(&self, name: &str) -> bool
Check if a step is completed.
Sourcepub fn is_step_started(&self, name: &str) -> bool
pub fn is_step_started(&self, name: &str) -> bool
Check if a step has been started (exists in step states).
Sourcepub fn get_step_result<T: DeserializeOwned>(&self, name: &str) -> Option<T>
pub fn get_step_result<T: DeserializeOwned>(&self, name: &str) -> Option<T>
Get the result of a completed step.
Sourcepub async fn record_step_start(&self, name: &str) -> Result<()>
pub async fn record_step_start(&self, name: &str) -> Result<()>
Record step start.
Mirrors WorkflowContext::record_step_start so workflow code that
uses ? on the call compiles unchanged in tests. The in-memory test
implementation can never fail, but the signature must match.
Sourcepub async fn record_step_complete(
&self,
name: &str,
result: Value,
) -> Result<()>
pub async fn record_step_complete( &self, name: &str, result: Value, ) -> Result<()>
Record step completion.
Sourcepub async fn record_step_failure(
&self,
name: &str,
_error: impl Into<String>,
) -> Result<()>
pub async fn record_step_failure( &self, name: &str, _error: impl Into<String>, ) -> Result<()>
Record step failure.
Sourcepub fn completed_step_names(&self) -> Vec<String>
pub fn completed_step_names(&self) -> Vec<String>
Get completed step names in order.
Sourcepub async fn sleep(&self, _duration: Duration) -> Result<()>
pub async fn sleep(&self, _duration: Duration) -> Result<()>
Durable sleep (no-op in tests, but records the intent).
Sourcepub fn sleep_called(&self) -> bool
pub fn sleep_called(&self) -> bool
Check if sleep was called.
Sourcepub fn env_mock(&self) -> &MockEnvProvider
pub fn env_mock(&self) -> &MockEnvProvider
Get the mock env provider for verification.
Sourcepub fn save_state(&self, key: &str, value: impl Serialize) -> Result<()>
pub fn save_state(&self, key: &str, value: impl Serialize) -> Result<()>
Save arbitrary state that persists across suspension points.
Sourcepub fn load_state<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>>
pub fn load_state<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>>
Load previously saved state. Returns None if the key doesn’t exist.
Sourcepub fn take_saved_state(&self) -> HashMap<String, Value>
pub fn take_saved_state(&self) -> HashMap<String, Value>
Get a snapshot of all saved state.
Trait Implementations§
Source§impl EnvAccess for TestWorkflowContext
impl EnvAccess for TestWorkflowContext
fn env_provider(&self) -> &dyn EnvProvider
fn env(&self, key: &str) -> Option<String>
fn env_or(&self, key: &str, default: &str) -> String
fn env_require(&self, key: &str) -> Result<String>
fn env_parse<T: FromStr>(&self, key: &str) -> Result<T>
Source§fn env_parse_or<T: FromStr>(&self, key: &str, default: T) -> Result<T>
fn env_parse_or<T: FromStr>(&self, key: &str, default: T) -> Result<T>
fn env_contains(&self, key: &str) -> bool
Auto Trait Implementations§
impl Freeze for TestWorkflowContext
impl !RefUnwindSafe for TestWorkflowContext
impl Send for TestWorkflowContext
impl Sync for TestWorkflowContext
impl Unpin for TestWorkflowContext
impl UnsafeUnpin for TestWorkflowContext
impl !UnwindSafe for TestWorkflowContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more