mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
88 lines
1.7 KiB
Rust
88 lines
1.7 KiB
Rust
mod helpers;
|
|
|
|
use helpers as h;
|
|
|
|
#[test]
|
|
fn pipeline_helper() {
|
|
let actual = h::pipeline(
|
|
r#"
|
|
open los_tres_amigos.txt
|
|
| from-csv
|
|
| get rusty_luck
|
|
| str --to-int
|
|
| sum
|
|
| echo "$it"
|
|
"#,
|
|
);
|
|
|
|
assert_eq!(
|
|
actual,
|
|
r#"open los_tres_amigos.txt | from-csv | get rusty_luck | str --to-int | sum | echo "$it""#
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn external_num() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats",
|
|
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | echo $it"
|
|
);
|
|
|
|
assert_eq!(actual, "10");
|
|
}
|
|
|
|
#[test]
|
|
fn external_has_correct_quotes() {
|
|
let actual = nu!(
|
|
cwd: ".",
|
|
r#"echo "hello world""#
|
|
);
|
|
|
|
assert_eq!(actual, r#"hello world"#);
|
|
}
|
|
|
|
#[test]
|
|
fn add_plugin() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", h::pipeline(
|
|
r#"
|
|
open cargo_sample.toml
|
|
| add dev-dependencies.newdep "1"
|
|
| get dev-dependencies.newdep
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "1");
|
|
}
|
|
|
|
#[test]
|
|
fn read_plugin() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", h::pipeline(
|
|
r#"
|
|
open fileA.txt
|
|
| read "{Name}={Value}"
|
|
| nth 1
|
|
| get Value
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "StupidLongName");
|
|
}
|
|
|
|
#[test]
|
|
fn edit_plugin() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", h::pipeline(
|
|
r#"
|
|
open cargo_sample.toml
|
|
| edit dev-dependencies.pretty_assertions "7"
|
|
| get dev-dependencies.pretty_assertions
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "7");
|
|
}
|