feat: Add the ability to set current dir and env vars
This commit is contained in:
41
tests/cmd.rs
41
tests/cmd.rs
@@ -11,6 +11,47 @@ fn expression() {
|
||||
assert_eq!(format!("{command:?}"), r#""echo" "test""#.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn current_dir() {
|
||||
let command = cmd!(
|
||||
cd "~/";
|
||||
"echo",
|
||||
"test",
|
||||
);
|
||||
|
||||
assert_eq!(format!("{command:?}"), r#"cd "~/" && "echo" "test""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn env_vars() {
|
||||
let command = cmd!(
|
||||
env {
|
||||
"TEST": "test",
|
||||
};
|
||||
"echo",
|
||||
"test",
|
||||
);
|
||||
|
||||
assert_eq!(format!("{command:?}"), r#"TEST="test" "echo" "test""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cd_env_vars() {
|
||||
let command = cmd!(
|
||||
cd "~/";
|
||||
env {
|
||||
"TEST": "test",
|
||||
};
|
||||
"echo",
|
||||
"test",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
format!("{command:?}"),
|
||||
r#"cd "~/" && TEST="test" "echo" "test""#
|
||||
);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(false, false, r#""echo" "test""#)]
|
||||
#[case(true, false, r#""echo" "test" "single""#)]
|
||||
|
||||
Reference in New Issue
Block a user