mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:06:03 +02:00
fix(nu-command/tests): further remove unnecessary pipeline() and cwd() (#8793)
# Description This PR further fixes tests as part of #8670 # 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:
committed by
GitHub
parent
1c5846e1fb
commit
35e8420780
@ -2,51 +2,47 @@ use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn columns() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(r#"
|
||||
let actual = nu!(pipeline(
|
||||
"
|
||||
echo [
|
||||
[arepas, color];
|
||||
[3, white]
|
||||
[8, yellow]
|
||||
[4, white]
|
||||
] | drop column | columns | length
|
||||
"#)
|
||||
);
|
||||
"
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_columns_positive_value() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(r#"
|
||||
echo [[a, b];[1,2]] | drop column -1
|
||||
"#)
|
||||
);
|
||||
let actual = nu!("echo [[a, b];[1,2]] | drop column -1");
|
||||
|
||||
assert!(actual.err.contains("use a positive value"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn more_columns_than_table_has() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(r#"
|
||||
let actual = nu!(pipeline(
|
||||
"
|
||||
echo [
|
||||
[arepas, color];
|
||||
[3, white]
|
||||
[8, yellow]
|
||||
[4, white]
|
||||
] | drop column 3 | columns | is-empty
|
||||
"#)
|
||||
);
|
||||
"
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rows() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(r#"
|
||||
let actual = nu!(pipeline(
|
||||
"
|
||||
echo [
|
||||
[arepas];
|
||||
|
||||
@ -57,43 +53,43 @@ fn rows() {
|
||||
| drop 2
|
||||
| get arepas
|
||||
| math sum
|
||||
"#)
|
||||
);
|
||||
"
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn more_rows_than_table_has() {
|
||||
let actual = nu!(cwd: ".", "[date] | drop 50 | length");
|
||||
let actual = nu!("[date] | drop 50 | length");
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nth_range_inclusive() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (2..3) | to json --raw");
|
||||
let actual = nu!("echo 10..15 | drop nth (2..3) | to json --raw");
|
||||
|
||||
assert_eq!(actual.out, "[10,11,14,15]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nth_range_exclusive() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth (1..<3) | to json --raw");
|
||||
let actual = nu!("echo 10..15 | drop nth (1..<3) | to json --raw");
|
||||
|
||||
assert_eq!(actual.out, "[10,13,14,15]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nth_missing_first_argument() {
|
||||
let actual = nu!(cwd: ".", "echo 10..15 | drop nth \"\"");
|
||||
let actual = nu!("echo 10..15 | drop nth \"\"");
|
||||
|
||||
assert!(actual.err.contains("int or range"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fail_on_non_iterator() {
|
||||
let actual = nu!(cwd: ".", pipeline("1 | drop 50"));
|
||||
let actual = nu!("1 | drop 50");
|
||||
|
||||
assert!(actual.err.contains("only_supports_this_input_type"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user