pub struct MockCommandExecutor { /* private fields */ }Expand description
Mock command executor for testing
Allows configuring responses for specific commands and verifying calls.
Implementations§
Source§impl MockCommandExecutor
impl MockCommandExecutor
pub fn new() -> Self
Sourcepub fn with_default_response(self, output: CommandOutput) -> Self
pub fn with_default_response(self, output: CommandOutput) -> Self
Set default response for unconfigured commands
Sourcepub fn on_command(&self, program: &str, args: &[&str], output: CommandOutput)
pub fn on_command(&self, program: &str, args: &[&str], output: CommandOutput)
Configure a response for a specific command pattern
The key is generated from program args[0] args[1] ...
Sourcepub fn calls(&self) -> Vec<CommandCall>
pub fn calls(&self) -> Vec<CommandCall>
Get all recorded calls
Sourcepub fn was_called(&self, program: &str, args: &[&str]) -> bool
pub fn was_called(&self, program: &str, args: &[&str]) -> bool
Check if a specific command was called
Sourcepub fn call_count(&self, program: &str) -> usize
pub fn call_count(&self, program: &str) -> usize
Get the number of times a command was called
Sourcepub fn clear_calls(&self)
pub fn clear_calls(&self)
Clear all recorded calls
Trait Implementations§
Source§impl Clone for MockCommandExecutor
impl Clone for MockCommandExecutor
Source§fn clone(&self) -> MockCommandExecutor
fn clone(&self) -> MockCommandExecutor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CommandExecutor for MockCommandExecutor
impl CommandExecutor for MockCommandExecutor
Source§fn execute(&self, program: &str, args: &[&str]) -> Result<CommandOutput>
fn execute(&self, program: &str, args: &[&str]) -> Result<CommandOutput>
Execute a command and return its output
Source§fn execute_in_dir(
&self,
program: &str,
args: &[&str],
dir: &str,
) -> Result<CommandOutput>
fn execute_in_dir( &self, program: &str, args: &[&str], dir: &str, ) -> Result<CommandOutput>
Execute a command in a specific directory
Source§impl Debug for MockCommandExecutor
impl Debug for MockCommandExecutor
Auto Trait Implementations§
impl Freeze for MockCommandExecutor
impl RefUnwindSafe for MockCommandExecutor
impl Send for MockCommandExecutor
impl Sync for MockCommandExecutor
impl Unpin for MockCommandExecutor
impl UnwindSafe for MockCommandExecutor
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