mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 05:25:59 +02:00
--no-edit
This commit is contained in:
@@ -203,9 +203,18 @@ fn errors_fetching_by_index_out_of_bounds() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.contains("Row not found"));
|
||||
assert!(actual.contains("There isn't a row indexed at '3'"));
|
||||
assert!(actual.contains("The table only has 3 rows (0..2)"))
|
||||
assert!(
|
||||
actual.contains("Row not found"),
|
||||
format!("actual: {:?}", actual)
|
||||
);
|
||||
assert!(
|
||||
actual.contains("There isn't a row indexed at 3"),
|
||||
format!("actual: {:?}", actual)
|
||||
);
|
||||
assert!(
|
||||
actual.contains("The table only has 3 rows (0 to 2)"),
|
||||
format!("actual: {:?}", actual)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -214,10 +223,13 @@ fn requires_at_least_one_column_member_path() {
|
||||
Playground::setup("get_test_9", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("andres.txt")]);
|
||||
|
||||
let actual = nu_error!(
|
||||
cwd: dirs.test(), "ls | get"
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), "ls | get | get type | echo $it"
|
||||
);
|
||||
|
||||
assert!(actual.contains("requires member parameter"));
|
||||
assert_eq!(
|
||||
actual,
|
||||
"[row: name, type, size, created, accessed, modified]"
|
||||
);
|
||||
})
|
||||
}
|
||||
|
@@ -189,7 +189,7 @@ fn open_can_parse_json() {
|
||||
fn open_can_parse_xml() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"open jonathan.xml | get rss.channel.item.link | echo $it"
|
||||
"open jonathan.xml | get rss.channel | get item | get link | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@@ -247,6 +247,80 @@ fn last_gets_last_row_when_no_amount_given() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get() {
|
||||
Playground::setup("get_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
nu_party_venue = "zion"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), h::pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| get nu_party_venue
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "zion");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_more_than_one_member() {
|
||||
Playground::setup("get_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[[fortune_tellers]]
|
||||
name = "Andrés N. Robalino"
|
||||
arepas = 1
|
||||
broken_builds = 0
|
||||
|
||||
[[fortune_tellers]]
|
||||
name = "Jonathan Turner"
|
||||
arepas = 1
|
||||
broken_builds = 1
|
||||
|
||||
[[fortune_tellers]]
|
||||
name = "Yehuda Katz"
|
||||
arepas = 1
|
||||
broken_builds = 1
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), h::pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| get fortune_tellers
|
||||
| get arepas broken_builds
|
||||
| sum
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "5");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_requires_at_least_one_member() {
|
||||
Playground::setup("first_test_3", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("andres.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), "ls | get"
|
||||
);
|
||||
|
||||
assert!(actual.contains("[row: name"), format!("{:?}", actual));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lines() {
|
||||
let actual = nu!(
|
||||
|
@@ -525,8 +525,7 @@ fn can_convert_table_to_bson_and_back_into_table() {
|
||||
| to-bson
|
||||
| from-bson
|
||||
| get root
|
||||
| nth 1
|
||||
| get b
|
||||
| get 1.b
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
|
Reference in New Issue
Block a user