2020-03-19 00:46:00 +01:00
|
|
|
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(
|
2020-04-06 09:16:14 +02:00
|
|
|
"meals.json",
|
2020-03-19 00:46:00 +01:00
|
|
|
r#"
|
2020-04-06 09:16:14 +02:00
|
|
|
{
|
|
|
|
meals: [
|
|
|
|
{description: "1 large egg", calories: 90},
|
|
|
|
{description: "1 cup white rice", calories: 250},
|
|
|
|
{description: "1 tablespoon fish oil", calories: 108}
|
|
|
|
]
|
|
|
|
}
|
2020-03-19 00:46:00 +01:00
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), pipeline(
|
|
|
|
r#"
|
2020-04-06 09:16:14 +02:00
|
|
|
open meals.json
|
|
|
|
| get meals
|
2020-03-19 00:46:00 +01:00
|
|
|
| get calories
|
|
|
|
| sum
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "448");
|
|
|
|
})
|
|
|
|
}
|