forked from extern/nushell
Tests
This commit is contained in:
parent
bfdd35d106
commit
13519f9601
@ -244,26 +244,45 @@ mod tests {
|
|||||||
use nu_test_support::fs::Stub::FileWithContent;
|
use nu_test_support::fs::Stub::FileWithContent;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_autoenv_vars_are_added(){
|
fn basic_autoenv_vars_are_added_and_removed(){
|
||||||
Playground::setup("autoenv_test_1", |dirs, sandbox| {
|
Playground::setup("autoenv_test_1", |dirs, sandbox| {
|
||||||
// sandbox.mkdir("autoenv_test_dir");
|
|
||||||
sandbox.with_files(vec![FileWithContent(
|
sandbox.with_files(vec![FileWithContent(
|
||||||
".nu-env",
|
".nu-env",
|
||||||
r#"
|
r#"
|
||||||
[env]
|
[env]
|
||||||
testkey = "testvalue"
|
testkey = "testvalue"
|
||||||
|
[scriptvars]
|
||||||
|
myscript = "echo 'myval'"
|
||||||
|
|
||||||
|
[scripts]
|
||||||
|
entryscripts = ["touch hello.txt"]
|
||||||
|
exitscripts = ["touch bye.txt"]
|
||||||
"#,
|
"#,
|
||||||
)]);
|
)]);
|
||||||
|
|
||||||
|
//Make sure basic keys are set
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: dirs.test(),
|
cwd: dirs.test(),
|
||||||
r#"autoenv trust
|
r#"autoenv trust
|
||||||
echo $nu.env.testkey"#
|
echo $nu.env.testkey"#
|
||||||
// r#"open .nu-env | from toml | get env | echo $it"#
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(actual.out.ends_with("testvalue"));
|
assert!(actual.out.ends_with("testvalue"));
|
||||||
|
|
||||||
|
// //Make sure script keys are set
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: dirs.test(),
|
||||||
|
r#"echo $nu.env.myscript"#
|
||||||
|
);
|
||||||
|
assert!(actual.out.ends_with("myval"));
|
||||||
|
|
||||||
|
//Back out of directory
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: dirs.test(),
|
||||||
|
r#"cd ..
|
||||||
|
echo $nu.env.testkey"#
|
||||||
|
);
|
||||||
|
assert!(!actual.out.ends_with("testvalue"));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user