default command introduced.

This commit is contained in:
Andrés N. Robalino
2019-11-24 04:20:08 -05:00
parent a74145961e
commit 1c830b5c95
5 changed files with 108 additions and 0 deletions

View File

@ -3,6 +3,38 @@ mod helpers;
use helpers as h;
use helpers::{Playground, Stub::*};
#[test]
fn default() {
Playground::setup("default_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"los_tres_amigos.json",
r#"
{
"amigos": [
{"name": "Yehuda"},
{"name": "Jonathan", "rusty_luck": 0},
{"name": "Andres", "rusty_luck": 0},
{"name":"GorbyPuff"}
]
}
"#,
)]);
let actual = nu!(
cwd: dirs.test(), h::pipeline(
r#"
open los_tres_amigos.json
| get amigos
| default rusty_luck 1
| get rusty_luck
| sum
| echo $it
"#
));
assert_eq!(actual, "2");
});
}
#[test]
fn compact_rows_where_given_column_is_empty() {
Playground::setup("compact_test_1", |dirs, sandbox| {