Skip to content

Commit

Permalink
improve 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 20f44eb commit da669f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/get_text/rerun_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mod tests {

#[test]
fn success() {
env::set_var("SHELL", "/bin/sh");
let cmd = "echo hello; echo world 1>&2; exit 1";
assert_eq!(
Some(vec!["world\n".to_string(), "hello\n".to_string()]),
Expand All @@ -42,7 +43,15 @@ mod tests {

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

#[test]
fn shell_var_not_set() {
env::remove_var("SHELL");
let cmd = "echo hello; echo world 1>&2";
assert!(matches!(rerun_command(cmd), Err(Error::Shell(_))));
}
}

0 comments on commit da669f4

Please sign in to comment.