mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:45:45 +02:00
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:
@ -1,44 +1,27 @@
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn row() {
|
||||
Playground::setup("merge_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
FileWithContentToBeTrimmed(
|
||||
"caballeros.csv",
|
||||
r#"
|
||||
name,country,luck
|
||||
Andrés,Ecuador,0
|
||||
JT,USA,0
|
||||
Jason,Canada,0
|
||||
Yehuda,USA,0
|
||||
"#,
|
||||
),
|
||||
FileWithContentToBeTrimmed(
|
||||
"new_caballeros.csv",
|
||||
r#"
|
||||
name,country,luck
|
||||
Andrés Robalino,Guayaquil Ecuador,1
|
||||
JT Turner,New Zealand,1
|
||||
"#,
|
||||
),
|
||||
]);
|
||||
let left_sample = r#"[[name, country, luck];
|
||||
[Andrés, Ecuador, 0],
|
||||
[JT, USA, 0],
|
||||
[Jason, Canada, 0],
|
||||
[Yehuda, USA, 0]]"#;
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open caballeros.csv
|
||||
| merge (open new_caballeros.csv)
|
||||
| where country in ["Guayaquil Ecuador" "New Zealand"]
|
||||
| get luck
|
||||
| math sum
|
||||
let right_sample = r#"[[name, country, luck];
|
||||
["Andrés Robalino", "Guayaquil Ecuador", 1],
|
||||
["JT Turner", "New Zealand", 1]]"#;
|
||||
|
||||
let actual = nu!(pipeline(&format!(
|
||||
r#" ({left_sample})
|
||||
| merge ({right_sample})
|
||||
| where country in ["Guayaquil Ecuador" "New Zealand"]
|
||||
| get luck
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
)));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
});
|
||||
assert_eq!(actual.out, "2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user