pub struct MockCliRunner { /* private fields */ }Expand description
Implementations§
Source§impl MockCliRunner
impl MockCliRunner
Sourcepub fn new() -> MockCliRunner
pub fn new() -> MockCliRunner
Create an empty mock (all calls will return errors by default).
Sourcepub fn push_run_response(&self, cmd: &str, result: Result<String, Error>)
pub fn push_run_response(&self, cmd: &str, result: Result<String, Error>)
Enqueue a response for the given command name.
Responses are returned in FIFO order. If the queue for cmd is
exhausted the mock returns Error::CommandFailed.
§Panics
Panics if the internal lock is poisoned.
Sourcepub fn set_tool_exists(&self, name: &str, exists: bool)
pub fn set_tool_exists(&self, name: &str, exists: bool)
Set whether CliRunner::tool_exists should return true or false
for the given tool name.
§Panics
Panics if the internal lock is poisoned.
Trait Implementations§
Source§impl CliRunner for MockCliRunner
impl CliRunner for MockCliRunner
Source§fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 str,
_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockCliRunner: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 str,
_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockCliRunner: 'async_trait,
Run an external command and return its captured stdout. Read more
Source§fn run_with_env<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 str,
_args: Vec<String>,
_env: Vec<(String, String)>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockCliRunner: 'async_trait,
fn run_with_env<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 str,
_args: Vec<String>,
_env: Vec<(String, String)>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockCliRunner: 'async_trait,
Run an external command with additional environment variables and
return its captured stdout. Read more
Source§fn tool_exists(&self, name: &str) -> bool
fn tool_exists(&self, name: &str) -> bool
Return
true when the given tool is available on PATH.Source§impl Default for MockCliRunner
impl Default for MockCliRunner
Source§fn default() -> MockCliRunner
fn default() -> MockCliRunner
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for MockCliRunner
impl RefUnwindSafe for MockCliRunner
impl Send for MockCliRunner
impl Sync for MockCliRunner
impl Unpin for MockCliRunner
impl UnsafeUnpin for MockCliRunner
impl UnwindSafe for MockCliRunner
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