histogram: support regular values. (#2300)

This commit is contained in:
Andrés N. Robalino
2020-08-04 04:57:25 -05:00
committed by GitHub
parent c48c092125
commit 7f35bfc005
2 changed files with 84 additions and 44 deletions

View File

@ -3,7 +3,7 @@ use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn summarizes() {
fn summarizes_by_column_given() {
Playground::setup("histogram_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"los_tres_caballeros.csv",
@ -34,9 +34,38 @@ fn summarizes() {
})
}
#[test]
fn summarizes_by_values() {
Playground::setup("histogram_test_2", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"los_tres_caballeros.csv",
r#"
first_name,last_name,rusty_at
Andrés,Robalino,Ecuador
Jonathan,Turner,Estados Unidos
Yehuda,Katz,Estados Unidos
"#,
)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open los_tres_caballeros.csv
| get rusty_at
| histogram
| where value == "Estados Unidos"
| get count
| echo $it
"#
));
assert_eq!(actual.out, "2");
})
}
#[test]
fn help() {
Playground::setup("histogram_test_help", |dirs, _sandbox| {
Playground::setup("histogram_test_3", |dirs, _sandbox| {
let help_command = nu!(
cwd: dirs.test(), pipeline(
r#"