mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
54d73748e4
# Description This PR implements modifications to command tests that write unnecessary json and csv to disk then load it with open, by using nuon literals instead. - Fixes #7189 # User-Facing Changes None # Tests + Formatting This only affects existing tests, which still pass.
86 lines
1.9 KiB
Rust
86 lines
1.9 KiB
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn changes_the_column_name() {
|
|
let sample = r#"
|
|
[["Andrés N. Robalino"],
|
|
["JT Turner"],
|
|
["Yehuda Katz"],
|
|
["Jason Gedge"]]
|
|
"#;
|
|
|
|
let actual = nu!(pipeline(&format!(
|
|
" {sample}
|
|
| wrap name
|
|
| rename mosqueteros
|
|
| get mosqueteros
|
|
| length
|
|
"
|
|
)));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
}
|
|
|
|
#[test]
|
|
fn keeps_remaining_original_names_given_less_new_names_than_total_original_names() {
|
|
let sample = r#"
|
|
[["Andrés N. Robalino"],
|
|
["JT Turner"],
|
|
["Yehuda Katz"],
|
|
["Jason Gedge"]]
|
|
"#;
|
|
|
|
let actual = nu!(pipeline(&format!(
|
|
r#"
|
|
{sample}
|
|
| wrap name
|
|
| default "arepa!" hit
|
|
| rename mosqueteros
|
|
| get hit
|
|
| length
|
|
"#
|
|
)));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
}
|
|
|
|
#[test]
|
|
fn errors_if_no_columns_present() {
|
|
let sample = r#"
|
|
[["Andrés N. Robalino"],
|
|
["JT Turner"],
|
|
["Yehuda Katz"],
|
|
["Jason Gedge"]]
|
|
"#;
|
|
|
|
let actual = nu!(pipeline(&format!(
|
|
"
|
|
{sample}
|
|
| rename mosqueteros
|
|
"
|
|
)));
|
|
|
|
assert!(actual.err.contains("command doesn't support"));
|
|
}
|
|
|
|
#[test]
|
|
fn errors_if_columns_param_is_empty() {
|
|
let sample = r#"
|
|
[["Andrés N. Robalino"],
|
|
["JT Turner"],
|
|
["Yehuda Katz"],
|
|
["Jason Gedge"]]
|
|
"#;
|
|
|
|
let actual = nu!(pipeline(&format!(
|
|
r#"
|
|
{sample}
|
|
| wrap name
|
|
| default "arepa!" hit
|
|
| rename --column {{}}
|
|
"#
|
|
)));
|
|
|
|
assert!(actual.err.contains("The column info cannot be empty"));
|
|
}
|