Skip to content

Commit

Permalink
add tests for rerun_command
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed Oct 19, 2024
1 parent 885ae6d commit 20f44eb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/get_text/rerun_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,23 @@ pub fn rerun_command(cmd: &str) -> Result<Option<Vec<String>>, Error> {

Ok(Some(vec![stderr, stdout]))
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn success() {
let cmd = "echo hello; echo world 1>&2; exit 1";
assert_eq!(
Some(vec!["world\n".to_string(), "hello\n".to_string()]),
rerun_command(cmd).unwrap()
);
}

#[test]
fn command_ran_successfully() {
let cmd = "echo hello; echo world 1>&2";
assert_eq!(None, rerun_command(cmd).unwrap());
}
}

0 comments on commit 20f44eb

Please sign in to comment.