Add unit test to command module

This commit is contained in:
Leonard Steppy 2024-12-17 15:40:53 +01:00
parent 9befc1fcf2
commit b6002b635d

View File

@ -84,4 +84,29 @@ impl Display for ExecutionError {
}
}
impl Error for ExecutionError {}
impl Error for ExecutionError {}
#[cfg(test)]
mod test {
use crate::command::{ExecutionError, LogRunnable, SpecificExecutionError};
use crate::logger::Logger;
use std::process::Command;
#[test]
fn test_unknown_command() {
let mut command = Command::new("a_command_which_def_doesnt_exist");
let Err(
e @ SpecificExecutionError {
error: ExecutionError::StartError(_),
..
},
) = command.args(["foo", "bar"]).run(&Logger::default())
else {
panic!("command shouldn't exist");
};
println!("{e}");
}
#[test]
fn test_error() {}
}