2019-07-16 10:28:55 +00:00
|
|
|
mod helpers;
|
2019-06-02 03:37:09 +00:00
|
|
|
|
2019-08-29 01:30:51 +00:00
|
|
|
use helpers as h;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn pipeline_helper() {
|
|
|
|
let actual = h::pipeline(
|
|
|
|
r#"
|
2019-09-03 00:49:51 +00:00
|
|
|
open los_tres_amigos.txt
|
|
|
|
| from-csv
|
|
|
|
| get rusty_luck
|
|
|
|
| str --to-int
|
|
|
|
| sum
|
2019-08-29 01:30:51 +00:00
|
|
|
| echo "$it"
|
2019-09-08 01:35:02 +00:00
|
|
|
"#,
|
|
|
|
);
|
2019-08-29 01:30:51 +00:00
|
|
|
|
2019-09-08 01:35:02 +00:00
|
|
|
assert_eq!(
|
|
|
|
actual,
|
|
|
|
r#"open los_tres_amigos.txt | from-csv | get rusty_luck | str --to-int | sum | echo "$it""#
|
|
|
|
);
|
2019-08-29 01:30:51 +00:00
|
|
|
}
|
|
|
|
|
2019-07-16 10:28:55 +00:00
|
|
|
#[test]
|
|
|
|
fn external_num() {
|
2019-08-29 01:30:51 +00:00
|
|
|
let actual = nu!(
|
2019-08-29 06:31:56 +00:00
|
|
|
cwd: "tests/fixtures/formats",
|
2019-07-22 03:52:57 +00:00
|
|
|
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | echo $it"
|
|
|
|
);
|
|
|
|
|
2019-08-29 01:30:51 +00:00
|
|
|
assert_eq!(actual, "10");
|
2019-07-16 10:28:55 +00:00
|
|
|
}
|
2019-06-24 07:59:23 +00:00
|
|
|
|
2019-08-02 16:33:52 +00:00
|
|
|
#[test]
|
|
|
|
fn external_has_correct_quotes() {
|
2019-08-29 06:31:56 +00:00
|
|
|
let actual = nu!(
|
2019-09-03 00:49:51 +00:00
|
|
|
cwd: ".",
|
2019-08-29 06:31:56 +00:00
|
|
|
r#"echo "hello world""#
|
|
|
|
);
|
2019-08-02 16:33:52 +00:00
|
|
|
|
2019-09-08 02:00:04 +00:00
|
|
|
assert_eq!(actual, r#"hello world"#);
|
2019-08-02 16:33:52 +00:00
|
|
|
}
|
|
|
|
|
2019-07-22 03:52:57 +00:00
|
|
|
#[test]
|
|
|
|
fn add_plugin() {
|
2019-08-29 01:30:51 +00:00
|
|
|
let actual = nu!(
|
2019-08-29 06:31:56 +00:00
|
|
|
cwd: "tests/fixtures/formats", h::pipeline(
|
|
|
|
r#"
|
2019-09-03 00:49:51 +00:00
|
|
|
open cargo_sample.toml
|
|
|
|
| add dev-dependencies.newdep "1"
|
|
|
|
| get dev-dependencies.newdep
|
2019-08-29 06:31:56 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
2019-07-22 03:52:57 +00:00
|
|
|
|
2019-08-29 01:30:51 +00:00
|
|
|
assert_eq!(actual, "1");
|
2019-07-22 03:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn edit_plugin() {
|
2019-08-29 01:30:51 +00:00
|
|
|
let actual = nu!(
|
2019-08-29 06:31:56 +00:00
|
|
|
cwd: "tests/fixtures/formats", h::pipeline(
|
|
|
|
r#"
|
2019-09-03 00:49:51 +00:00
|
|
|
open cargo_sample.toml
|
|
|
|
| edit dev-dependencies.pretty_assertions "7"
|
|
|
|
| get dev-dependencies.pretty_assertions
|
2019-08-29 06:31:56 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
2019-07-22 03:52:57 +00:00
|
|
|
|
2019-08-29 01:30:51 +00:00
|
|
|
assert_eq!(actual, "7");
|
2019-07-22 03:52:57 +00:00
|
|
|
}
|