mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:36:08 +02:00
group by to table empty (#16219)
- fixes #16217 # Description > `group-by --to-table` does not always return a table (a list) > ```nushell > [] | group-by --to-table something > #=> ╭──────────────╮ > #=> │ empty record │ > #=> ╰──────────────╯ > ``` Fixed: ```nushell [] | group-by --to-table something #=> ╭────────────╮ #=> │ empty list │ #=> ╰────────────╯ ``` # Tests + Formatting +1 test --------- Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
This commit is contained in:
@ -68,9 +68,18 @@ fn errors_if_column_not_found() {
|
||||
|
||||
#[test]
|
||||
fn group_by_on_empty_list_returns_empty_record() {
|
||||
let actual = nu!("[[a b]; [1 2]] | where false | group-by a");
|
||||
let actual = nu!("[[a b]; [1 2]] | where false | group-by a | to nuon --raw");
|
||||
let expected = r#"{}"#;
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(actual.out.contains("empty record"));
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_by_to_table_on_empty_list_returns_empty_list() {
|
||||
let actual = nu!("[[a b]; [1 2]] | where false | group-by --to-table a | to nuon --raw");
|
||||
let expected = r#"[]"#;
|
||||
assert!(actual.err.is_empty());
|
||||
assert_eq!(actual.out, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user