forked from extern/nushell
Update description and error types for split-by
(#10865)
# Description `split-by` only works on a `Record`, the error type was updated to match, and now uses a more-specific type. (Two type fixes for the price of one!) The `usage` was updated to say "record" as well # User-Facing Changes * Providing the wrong type to `split-by` now gives an error messages with the correct required input type Previously: ``` ❯ ls | get name | split-by type Error: × unsupported input ╭─[entry #267:1:1] 1 │ ls | get name | split-by type · ─┬─ · ╰── requires a table with one row for splitting ╰──── ``` With this PR: ``` ❯ ls | get name | split-by type Error: nu:🐚:type_mismatch × Type mismatch. ╭─[entry #1:1:1] 1 │ ls | get name | split-by type · ─┬─ · ╰── requires a record to split ╰──── ``` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting Only generated commands need to be updated --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
@ -31,7 +31,16 @@ fn splits() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors_if_no_table_given_as_input() {
|
||||
fn errors_if_no_input() {
|
||||
Playground::setup("split_by_no_input", |dirs, _sandbox| {
|
||||
let actual = nu!(cwd: dirs.test(), pipeline("split-by type"));
|
||||
|
||||
assert!(actual.err.contains("no input value was piped in"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors_if_non_record_input() {
|
||||
Playground::setup("split_by_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
@ -40,7 +49,11 @@ fn errors_if_no_table_given_as_input() {
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
let input_mismatch = nu!(cwd: dirs.test(), pipeline("5 | split-by type"));
|
||||
|
||||
assert!(input_mismatch.err.contains("doesn't support int input"));
|
||||
|
||||
let only_supports = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
"
|
||||
ls
|
||||
@ -49,6 +62,8 @@ fn errors_if_no_table_given_as_input() {
|
||||
"
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("requires a table"));
|
||||
assert!(only_supports
|
||||
.err
|
||||
.contains("only Record input data is supported"));
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user