Fix(tests/nu-command): remove unnecessary cwd() and pipeline(), etc (#8711)

# Description

This PR aims to cover the tests under nu-command as part of this issue
#8670 to clean up any unnecessary wrapping funcs like `cwd(".")` or
`pipeline()`, etc.

This PR is still WIP and opening as draft to get first impressions and
feedback on a few tests before I go on changing more.


# User-Facing Changes

None

# Tests + Formatting

None

# After Submitting

None

---------

Signed-off-by: Harshal Chaudhari <harshal.chaudhary@gmail.com>
Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
This commit is contained in:
Harshal Chaudhari
2023-04-02 16:25:05 +01:00
committed by GitHub
parent 61fa826159
commit 3fab427383
4 changed files with 35 additions and 156 deletions

View File

@ -49,47 +49,23 @@ fn alias_hiding_2() {
#[test]
fn alias_fails_with_invalid_name() {
let err_msg = "name can't be a number, a filesize, or contain a hash # or caret ^";
let actual = nu!(
cwd: ".", pipeline(
r#"
alias 1234 = echo "test"
"#
));
let actual = nu!(r#" alias 1234 = echo "test" "#);
assert!(actual.err.contains(err_msg));
let actual = nu!(
cwd: ".", pipeline(
r#"
alias 5gib = echo "test"
"#
));
let actual = nu!(r#" alias 5gib = echo "test" "#);
assert!(actual.err.contains(err_msg));
let actual = nu!(
cwd: ".", pipeline(
r#"
alias "te#t" = echo "test"
"#
));
let actual = nu!(r#" alias "te#t" = echo "test" "#);
assert!(actual.err.contains(err_msg));
let actual = nu!(
cwd: ".", pipeline(
r#"
alias ^foo = echo "bar"
"#
));
let actual = nu!(r#" alias ^foo = echo "bar" "#);
assert!(actual.err.contains(err_msg));
}
#[test]
fn cant_alias_keyword() {
let actual = nu!(
cwd: ".", pipeline(
r#"
alias ou = let
"#
));
let actual = nu!(r#" alias ou = let "#);
assert!(actual.err.contains("cant_alias_keyword"));
}