pub struct OperatorTestHarness<T: FFIOperator> { /* private fields */ }Expand description
Test harness for FFI operators
This harness provides a complete testing environment for FFI operators with:
- Mock FFI context with test-specific callbacks
- State management via TestContext
- Version tracking
- Log capture (to stderr for now)
- Full support for apply() and get_rows()
Implementations§
Source§impl<T: FFIOperator> OperatorTestHarness<T>
impl<T: FFIOperator> OperatorTestHarness<T>
Sourcepub fn builder() -> TestHarnessBuilder<T>
pub fn builder() -> TestHarnessBuilder<T>
Create a new test harness builder
Sourcepub fn apply(&mut self, input: FlowChange) -> Result<FlowChange>
pub fn apply(&mut self, input: FlowChange) -> Result<FlowChange>
Apply a flow change to the operator
Sourcepub fn get_rows(
&mut self,
row_numbers: &[RowNumber],
) -> Result<Vec<Option<Row>>>
pub fn get_rows( &mut self, row_numbers: &[RowNumber], ) -> Result<Vec<Option<Row>>>
Get rows by their row numbers
Sourcepub fn version(&self) -> CommitVersion
pub fn version(&self) -> CommitVersion
Get the current version
Sourcepub fn set_version(&mut self, version: CommitVersion)
pub fn set_version(&mut self, version: CommitVersion)
Set the current version
Sourcepub fn state(&self) -> TestStateStore
pub fn state(&self) -> TestStateStore
Get access to the state store for assertions
Sourcepub fn assert_state<K>(&self, key: K, expected: Value)where
K: EncodableKey,
pub fn assert_state<K>(&self, key: K, expected: Value)where
K: EncodableKey,
Assert that a state key exists with the given value
Sourcepub fn clear_logs(&self)
pub fn clear_logs(&self)
Clear captured log messages
Sourcepub fn snapshot_state(&self) -> HashMap<EncodedKey, EncodedValues>
pub fn snapshot_state(&self) -> HashMap<EncodedKey, EncodedValues>
Take a snapshot of the current state
Sourcepub fn restore_state(&mut self, snapshot: HashMap<EncodedKey, EncodedValues>)
pub fn restore_state(&mut self, snapshot: HashMap<EncodedKey, EncodedValues>)
Restore state from a snapshot
Sourcepub fn create_operator_context(&mut self) -> OperatorContext
pub fn create_operator_context(&mut self) -> OperatorContext
Create an operator context for direct access
This is useful for testing components that need an OperatorContext without going through the apply() or get_rows() methods.
§Example
ⓘ
let mut harness = TestHarnessBuilder::<MyOperator>::new().build()?;
let mut ctx = harness.create_operator_context();
let (row_num, is_new) = ctx.get_or_create_row_number(harness.operator(), &key)?;Sourcepub fn operator_mut(&mut self) -> &mut T
pub fn operator_mut(&mut self) -> &mut T
Get a mutable reference to the operator
Sourcepub fn node_id(&self) -> FlowNodeId
pub fn node_id(&self) -> FlowNodeId
Get the node ID
Auto Trait Implementations§
impl<T> Freeze for OperatorTestHarness<T>where
T: Freeze,
impl<T> RefUnwindSafe for OperatorTestHarness<T>where
T: RefUnwindSafe,
impl<T> !Send for OperatorTestHarness<T>
impl<T> !Sync for OperatorTestHarness<T>
impl<T> Unpin for OperatorTestHarness<T>where
T: Unpin,
impl<T> UnwindSafe for OperatorTestHarness<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
Mutably borrows from an owned value. Read more