Add unlet_env command (#3629)

* Add ability to remove env variables

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Implement unlet_env command

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Update parameter description

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Migrate to new filestructure

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Added tests for unlet-env

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Formatting

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
Nathan Thomas
2021-06-18 20:00:07 -07:00
committed by GitHub
parent 26899bc0f0
commit 9e39284de9
5 changed files with 96 additions and 0 deletions

View File

@ -411,6 +411,31 @@ fn let_env_variable() {
assert_eq!(actual.out, "hello world");
}
#[test]
fn unlet_env_variable() {
let actual = nu!(
cwd: ".",
r#"
let-env TEST_VAR = "hello world"
unlet-env TEST_VAR
echo $nu.env.TEST_VAR
"#
);
assert!(actual.err.contains("did you mean"));
}
#[test]
fn unlet_nonexistent_variable() {
let actual = nu!(
cwd: ".",
r#"
unlet-env NONEXISTENT_VARIABLE
"
);
assert!(actual.err.contains("did you mean"));
}
#[test]
fn let_env_doesnt_leak() {
let actual = nu!(