2019-12-17 19:54:39 +01:00
|
|
|
use nu_test_support::{nu, pipeline};
|
2019-12-15 17:15:06 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn wrap_rows_into_a_row() {
|
2023-11-29 23:21:34 +01:00
|
|
|
let sample = r#"
|
|
|
|
[[first_name, last_name];
|
|
|
|
[Andrés, Robalino],
|
|
|
|
[JT, Turner],
|
|
|
|
[Yehuda, Katz]]
|
|
|
|
"#;
|
2019-12-15 17:15:06 +01:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
let actual = nu!(pipeline(&format!(
|
|
|
|
"
|
|
|
|
{sample}
|
2019-12-15 17:15:06 +01:00
|
|
|
| wrap caballeros
|
|
|
|
| get caballeros
|
2022-02-09 11:58:54 +01:00
|
|
|
| get 0
|
2019-12-15 17:15:06 +01:00
|
|
|
| get last_name
|
2023-07-21 17:32:37 +02:00
|
|
|
"
|
2023-11-29 23:21:34 +01:00
|
|
|
)));
|
2019-12-15 17:15:06 +01:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
assert_eq!(actual.out, "Robalino");
|
2019-12-15 17:15:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn wrap_rows_into_a_table() {
|
2023-11-29 23:21:34 +01:00
|
|
|
let sample = r#"
|
|
|
|
[[first_name, last_name];
|
|
|
|
[Andrés, Robalino],
|
|
|
|
[JT, Turner],
|
|
|
|
[Yehuda, Katz]]
|
|
|
|
"#;
|
2019-12-15 17:15:06 +01:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
let actual = nu!(pipeline(&format!(
|
|
|
|
"
|
|
|
|
{sample}
|
2019-12-15 17:15:06 +01:00
|
|
|
| get last_name
|
|
|
|
| wrap caballero
|
2022-02-09 11:58:54 +01:00
|
|
|
| get 2
|
2019-12-15 17:15:06 +01:00
|
|
|
| get caballero
|
2023-07-21 17:32:37 +02:00
|
|
|
"
|
2023-11-29 23:21:34 +01:00
|
|
|
)));
|
2019-12-15 17:15:06 +01:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
assert_eq!(actual.out, "Katz");
|
2019-12-15 17:15:06 +01:00
|
|
|
}
|