Fix ignore-errors for select (#6896)

* Fix ignore-errors for select

* fix Value::List match

* fix invalid rows

* add tests

* fix ListStream match

* add one more test for ListStream

* add more tests

* tweak words
This commit is contained in:
nibon7
2022-11-10 05:57:44 +08:00
committed by GitHub
parent df94052180
commit c600c1ebe7
2 changed files with 132 additions and 30 deletions

View File

@ -169,6 +169,7 @@ fn select_ignores_errors_succesfully1() {
"#
));
assert!(actual.out.is_empty());
assert!(actual.err.is_empty());
}
@ -181,5 +182,87 @@ fn select_ignores_errors_succesfully2() {
"#
));
assert!(actual.out.is_empty());
assert!(actual.err.is_empty());
}
#[test]
fn select_ignores_errors_succesfull3() {
let actual = nu!(
cwd: ".", pipeline(
r#"sys | select -i invalid_key"#
));
assert!(actual.out.is_empty());
assert!(actual.err.is_empty());
}
#[test]
fn select_ignores_errors_succesfully4() {
let actual = nu!(
cwd: ".", pipeline(
r#"[a b c] | select -i invalid_key"#
));
assert!(actual.out.is_empty());
assert!(actual.err.is_empty());
}
#[test]
fn select_ignores_errors_successfully5() {
let actual = nu!(
cwd: ".", pipeline(
r#"[a b c] | select -i 0.0"#
));
assert!(actual.out.is_empty());
assert!(actual.err.is_empty());
}
#[test]
fn select_ignores_errors_successfully6() {
let actual = nu!(
cwd: ".", pipeline(
r#""key val\na 1\nb 2\n" | lines | split column -c " " | select -i "100""#
));
assert!(actual.out.is_empty());
assert!(actual.err.is_empty());
}
#[test]
fn select_failed1() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[{a: 1, b: 2} {a: 3, b: 5} {a: 3}] | select b
"#
));
assert!(actual.out.is_empty());
assert!(actual.err.contains("cannot find column"));
}
#[test]
fn select_failed2() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[{a: 1} {a: 2} {a: 3}] | select b
"#
));
assert!(actual.out.is_empty());
assert!(actual.err.contains("cannot find column"));
}
#[test]
fn select_failed3() {
let actual = nu!(
cwd: ".", pipeline(
r#""key val\na 1\nb 2\n" | lines | split column -c " " | select "100""#
));
assert!(actual.out.is_empty());
assert!(actual.err.contains("cannot find column"));
}