2020-04-30 06:18:24 +02:00
|
|
|
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
|
|
|
|
Jonathan,USA,0
|
|
|
|
Jason,Canada,0
|
|
|
|
Yehuda,USA,0
|
|
|
|
"#,
|
|
|
|
),
|
|
|
|
FileWithContentToBeTrimmed(
|
|
|
|
"new_caballeros.csv",
|
|
|
|
r#"
|
|
|
|
name,country,luck
|
|
|
|
Andrés Robalino,Guayaquil Ecuador,1
|
|
|
|
Jonathan Turner,New Zealand,1
|
|
|
|
"#,
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
|
|
|
|
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
|
2020-06-19 04:02:01 +02:00
|
|
|
| math sum
|
2020-04-30 06:18:24 +02:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 13:03:43 +02:00
|
|
|
assert_eq!(actual.out, "2");
|
2020-04-30 06:18:24 +02:00
|
|
|
})
|
|
|
|
}
|