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.
This commit is contained in:
Renan Ribeiro
2023-11-29 19:21:34 -03:00
committed by GitHub
parent d08e254d16
commit 54d73748e4
20 changed files with 414 additions and 760 deletions

View File

@ -5,31 +5,25 @@ use pretty_assertions::assert_eq;
#[test]
fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
Playground::setup("internal_to_external_pipe_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"nu_times.csv",
"
name,rusty_luck,origin
Jason,1,Canada
JT,1,New Zealand
Andrés,1,Ecuador
AndKitKatz,1,Estados Unidos
",
)]);
let sample = r#"
[[name, rusty_luck, origin];
[Jason, 1, Canada],
[JT, 1, "New Zealand"],
[Andrés, 1, Ecuador],
[AndKitKatz, 1, "Estados Unidos"]]
"#;
let actual = nu!(
cwd: dirs.test(), pipeline(
let actual = nu!(pipeline(&format!(
"
open nu_times.csv
{sample}
| get origin
| each { |it| nu --testbin cococo $it | nu --testbin chop }
| each {{ |it| nu --testbin cococo $it | nu --testbin chop }}
| get 2
"
));
)));
// chop will remove the last escaped double quote from \"Estados Unidos\"
assert_eq!(actual.out, "Ecuado");
})
// chop will remove the last escaped double quote from \"Estados Unidos\"
assert_eq!(actual.out, "Ecuado");
}
#[test]
@ -111,7 +105,7 @@ fn subexpression_handles_dot() {
));
assert_eq!(actual.out, "AndKitKat");
})
});
}
#[test]