pub struct TestResult<T> { /* private fields */ }Expand description
Result of a durable execution test.
Contains the execution outcome, captured operations, and provides methods for inspecting and verifying workflow behavior.
§Type Parameters
T- The type of the successful result value
§Examples
use durable_execution_sdk_testing::{TestResult, ExecutionStatus};
// After running a test
let result: TestResult<String> = runner.run("input").await?;
// Check status
assert_eq!(result.get_status(), ExecutionStatus::Succeeded);
// Get the result value
let value = result.get_result()?;
assert_eq!(value, "expected output");
// Inspect operations
let ops = result.get_operations();
assert_eq!(ops.len(), 3);Implementations§
Source§impl<T> TestResult<T>
impl<T> TestResult<T>
Sourcepub fn success(result: T, operations: Vec<Operation>) -> Self
pub fn success(result: T, operations: Vec<Operation>) -> Self
Creates a new successful TestResult.
Sourcepub fn failure(error: TestResultError, operations: Vec<Operation>) -> Self
pub fn failure(error: TestResultError, operations: Vec<Operation>) -> Self
Creates a new failed TestResult.
Sourcepub fn with_status(status: ExecutionStatus, operations: Vec<Operation>) -> Self
pub fn with_status(status: ExecutionStatus, operations: Vec<Operation>) -> Self
Creates a new TestResult with a specific status.
Sourcepub fn set_result(&mut self, result: T)
pub fn set_result(&mut self, result: T)
Sets the result value.
Sourcepub fn set_error(&mut self, error: TestResultError)
pub fn set_error(&mut self, error: TestResultError)
Sets the error.
Sourcepub fn set_invocations(&mut self, invocations: Vec<Invocation>)
pub fn set_invocations(&mut self, invocations: Vec<Invocation>)
Sets the invocations.
Sourcepub fn add_invocation(&mut self, invocation: Invocation)
pub fn add_invocation(&mut self, invocation: Invocation)
Adds an invocation.
Sourcepub fn set_history_events(&mut self, events: Vec<HistoryEvent>)
pub fn set_history_events(&mut self, events: Vec<HistoryEvent>)
Sets the history events.
Sourcepub fn add_history_event(&mut self, event: HistoryEvent)
pub fn add_history_event(&mut self, event: HistoryEvent)
Adds a history event.
Sourcepub fn set_nodejs_history_events(&mut self, events: Vec<NodeJsHistoryEvent>)
pub fn set_nodejs_history_events(&mut self, events: Vec<NodeJsHistoryEvent>)
Sets the Node.js SDK compatible history events.
These events match the Node.js SDK’s event history format exactly, enabling cross-SDK history comparison.
Sourcepub fn add_nodejs_history_event(&mut self, event: NodeJsHistoryEvent)
pub fn add_nodejs_history_event(&mut self, event: NodeJsHistoryEvent)
Adds a Node.js SDK compatible history event.
Sourcepub fn get_status(&self) -> ExecutionStatus
pub fn get_status(&self) -> ExecutionStatus
Sourcepub fn get_result(&self) -> Result<&T, TestError>
pub fn get_result(&self) -> Result<&T, TestError>
Gets the result value if execution succeeded.
§Returns
Ok(&T)- Reference to the result value if execution succeededErr(TestError)- Error if execution failed or result is not available
Sourcepub fn get_error(&self) -> Result<&TestResultError, &str>
pub fn get_error(&self) -> Result<&TestResultError, &str>
Gets the error if execution failed.
§Returns
Ok(&TestResultError)- Reference to the error if execution failedErr(&str)- Error message if execution succeeded or error is not available
Sourcepub fn get_operations(&self) -> &[Operation]
pub fn get_operations(&self) -> &[Operation]
Gets all operations from the execution.
§Returns
A slice of all operations captured during execution, in execution order.
Sourcepub fn get_operations_by_status(
&self,
status: OperationStatus,
) -> Vec<&Operation>
pub fn get_operations_by_status( &self, status: OperationStatus, ) -> Vec<&Operation>
Sourcepub fn get_invocations(&self) -> &[Invocation]
pub fn get_invocations(&self) -> &[Invocation]
Gets handler invocation details.
§Returns
A slice of invocation details for each time the handler was invoked.
Sourcepub fn get_history_events(&self) -> &[HistoryEvent]
pub fn get_history_events(&self) -> &[HistoryEvent]
Gets history events from the execution.
§Returns
A slice of history events that occurred during execution.
Sourcepub fn get_nodejs_history_events(&self) -> &[NodeJsHistoryEvent]
pub fn get_nodejs_history_events(&self) -> &[NodeJsHistoryEvent]
Gets Node.js SDK compatible history events from the execution.
Returns events in the Node.js SDK compatible format, suitable for cross-SDK history comparison. These events use PascalCase field names and include detailed event-specific information.
§Returns
A slice of Node.js-compatible history events that occurred during execution.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Checks if the execution succeeded.
Sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
Checks if the execution failed.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Checks if the execution is still running.
Sourcepub fn operation_count(&self) -> usize
pub fn operation_count(&self) -> usize
Gets the number of operations.
Sourcepub fn invocation_count(&self) -> usize
pub fn invocation_count(&self) -> usize
Gets the number of invocations.
Source§impl<T> TestResult<T>
impl<T> TestResult<T>
Sourcepub fn print(&self)
pub fn print(&self)
Prints a formatted table of all operations to stdout.
Uses default column configuration showing name, type, status, and timing information.
Sourcepub fn print_with_config(&self, config: PrintConfig)
pub fn print_with_config(&self, config: PrintConfig)
Prints a formatted table of operations with custom column configuration.
§Arguments
config- Configuration specifying which columns to include
Source§impl<T: DeserializeOwned> TestResult<T>
impl<T: DeserializeOwned> TestResult<T>
Sourcepub fn deserialize_result_from_json(json: &str) -> Result<T, TestError>
pub fn deserialize_result_from_json(json: &str) -> Result<T, TestError>
Attempts to deserialize the result from a JSON string.
This is useful when the result was stored as a serialized string and needs to be deserialized into the expected type.
Trait Implementations§
Source§impl<T: Clone> Clone for TestResult<T>
impl<T: Clone> Clone for TestResult<T>
Source§fn clone(&self) -> TestResult<T>
fn clone(&self) -> TestResult<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for TestResult<T>
impl<T: Debug> Debug for TestResult<T>
Source§impl<'de, T> Deserialize<'de> for TestResult<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for TestResult<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<T> Freeze for TestResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for TestResult<T>where
T: RefUnwindSafe,
impl<T> Send for TestResult<T>where
T: Send,
impl<T> Sync for TestResult<T>where
T: Sync,
impl<T> Unpin for TestResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for TestResult<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for TestResult<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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