nushell/crates/nu-command/tests/commands/wrap.rs
Renan Ribeiro 54d73748e4
Remove file I/O from tests that don't need it (#11182)
# 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.
2023-11-29 23:21:34 +01:00

46 lines
999 B
Rust

use nu_test_support::{nu, pipeline};
#[test]
fn wrap_rows_into_a_row() {
let sample = r#"
[[first_name, last_name];
[Andrés, Robalino],
[JT, Turner],
[Yehuda, Katz]]
"#;
let actual = nu!(pipeline(&format!(
"
{sample}
| wrap caballeros
| get caballeros
| get 0
| get last_name
"
)));
assert_eq!(actual.out, "Robalino");
}
#[test]
fn wrap_rows_into_a_table() {
let sample = r#"
[[first_name, last_name];
[Andrés, Robalino],
[JT, Turner],
[Yehuda, Katz]]
"#;
let actual = nu!(pipeline(&format!(
"
{sample}
| get last_name
| wrap caballero
| get 2
| get caballero
"
)));
assert_eq!(actual.out, "Katz");
}