feat: Default env variables
This commit is contained in:
33
tests/cmd.rs
33
tests/cmd.rs
@@ -1,6 +1,8 @@
|
||||
extern crate comlexr;
|
||||
extern crate rstest;
|
||||
|
||||
use std::env;
|
||||
|
||||
use comlexr::cmd;
|
||||
use rstest::rstest;
|
||||
|
||||
@@ -35,6 +37,37 @@ fn env_vars() {
|
||||
assert_eq!(format!("{command:?}"), r#"TEST="test" "echo" "test""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conditional_env_vars() {
|
||||
env::set_var("TEST", "realvalue");
|
||||
env::set_var("TEST2", "won't see");
|
||||
|
||||
let command = cmd!(
|
||||
env {
|
||||
"TEST":? "test",
|
||||
"TEST2": "test2"
|
||||
};
|
||||
"echo",
|
||||
"test",
|
||||
);
|
||||
|
||||
assert_eq!(format!("{command:?}"), r#"TEST2="test2" "echo" "test""#);
|
||||
|
||||
let command = cmd!(
|
||||
env {
|
||||
"TEST": "test",
|
||||
"TEST2": "test2"
|
||||
};
|
||||
"echo",
|
||||
"test",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
format!("{command:?}"),
|
||||
r#"TEST="test" TEST2="test2" "echo" "test""#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cd_env_vars() {
|
||||
let command = cmd!(
|
||||
|
||||
Reference in New Issue
Block a user