Make sum plugin as internal command. (#1501)

This commit is contained in:
Andrés N. Robalino
2020-03-18 18:46:00 -05:00
committed by GitHub
parent 390deb4ff7
commit 21a543a901
18 changed files with 278 additions and 204 deletions

View File

@ -29,6 +29,7 @@ mod save;
mod sort_by;
mod split_by;
mod split_column;
mod sum;
mod touch;
mod uniq;
mod where_;

View File

@ -0,0 +1,30 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn all() {
Playground::setup("sum_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"meals.csv",
r#"
description,calories
"1 large egg",90
"1 cup white rice",250
"1 tablespoon fish oil",108
"#,
)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open meals.csv
| get calories
| sum
| echo $it
"#
));
assert_eq!(actual, "448");
})
}

View File

@ -4,7 +4,7 @@ use nu_test_support::{nu, pipeline};
#[test]
fn wrap_rows_into_a_row() {
Playground::setup("embed_test_1", |dirs, sandbox| {
Playground::setup("wrap_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"los_tres_caballeros.txt",
r#"
@ -34,7 +34,7 @@ fn wrap_rows_into_a_row() {
#[test]
fn wrap_rows_into_a_table() {
Playground::setup("embed_test_2", |dirs, sandbox| {
Playground::setup("wrap_test_2", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"los_tres_caballeros.txt",
r#"