Move off 'sum' to internal command 'count' for tests.

This commit is contained in:
Andrés N. Robalino
2019-10-15 05:16:47 -05:00
parent 96ef478fbc
commit 5ed1ed54a6
2 changed files with 48 additions and 45 deletions

View File

@ -7,48 +7,66 @@ use helpers::{Playground, Stub::*};
fn first_gets_first_rows_by_amount() {
Playground::setup("first_test_1", |dirs, sandbox| {
sandbox.with_files(vec![
EmptyFile("los.1.txt"),
EmptyFile("tres.1.txt"),
EmptyFile("amigos.1.txt"),
EmptyFile("arepas.1.clu"),
EmptyFile("los.txt"),
EmptyFile("tres.txt"),
EmptyFile("amigos.txt"),
EmptyFile("arepas.clu"),
]);
let actual = nu!(
cwd: dirs.test(), h::pipeline(
r#"
ls
| get name
| first 2
| split-column "."
| get Column2
| str --to-int
| sum
| first 3
| count
| echo $it
"#
));
assert_eq!(actual, "2");
assert_eq!(actual, "3");
})
}
#[test]
fn first_gets_first_row_when_no_amount_given() {
fn first_gets_all_rows_if_amount_higher_than_all_rows() {
Playground::setup("first_test_2", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("los-tres-amigos.PASSTEST.txt")]);
sandbox.with_files(vec![
EmptyFile("los.txt"),
EmptyFile("tres.txt"),
EmptyFile("amigos.txt"),
EmptyFile("arepas.clu"),
]);
let actual = nu!(
cwd: dirs.test(), h::pipeline(
r#"
ls
| get name
| first
| split-column "."
| get Column2
| first 99
| count
| echo $it
"#
));
assert_eq!(actual, "PASSTEST");
assert_eq!(actual, "4");
})
}
#[test]
fn first_gets_first_row_when_no_amount_given() {
Playground::setup("first_test_3", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
let actual = nu!(
cwd: dirs.test(), h::pipeline(
r#"
ls
| first
| count
| echo $it
"#
));
assert_eq!(actual, "1");
})
}