Make str more strict. (#2173)

This commit is contained in:
Andrés N. Robalino
2020-07-14 10:04:00 -05:00
committed by GitHub
parent f2c4d22739
commit e9313a61af
7 changed files with 105 additions and 4 deletions

View File

@ -37,8 +37,9 @@ fn condition_is_met() {
| skip 2
| split column ','
| headers
| skip-while "Chickens Collction" != "Blue Chickens"
| skip-while "Chicken Collection" != "Blue Chickens"
| keep-until "Chicken Collection" == "Red Chickens"
| skip 1
| str to-int "31/04/2020"
| get "31/04/2020"
| math sum

View File

@ -44,6 +44,7 @@ mod save;
mod select;
mod semicolon;
mod skip_until;
mod skip_while;
mod sort_by;
mod split_by;
mod split_column;

View File

@ -38,6 +38,7 @@ fn condition_is_met() {
| split column ','
| headers
| skip-until "Chicken Collection" == "Red Chickens"
| skip 1
| str to-int "31/04/2020"
| get "31/04/2020"
| math sum

View File

@ -0,0 +1,51 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn condition_is_met() {
Playground::setup("skip-while_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"caballeros.txt",
r#"
CHICKEN SUMMARY report date: April 29th, 2020
--------------------------------------------------------------------
Chicken Collection,29/04/2020,30/04/2020,31/04/2020,
Yellow Chickens,,,
Andrés,0,0,1
Jonathan,0,0,1
Jason,0,0,1
Yehuda,0,0,1
Blue Chickens,,,
Andrés,0,0,1
Jonathan,0,0,1
Jason,0,0,1
Yehuda,0,0,2
Red Chickens,,,
Andrés,0,0,1
Jonathan,0,0,1
Jason,0,0,1
Yehuda,0,0,3
"#,
)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open --raw caballeros.txt
| lines
| skip 2
| split column ','
| headers
| skip-while "Chicken Collection" != "Red Chickens"
| skip 1
| str to-int "31/04/2020"
| get "31/04/2020"
| math sum
| echo $it
"#
));
assert_eq!(actual.out, "6");
})
}