Files
nushell/crates/nu-command/tests/commands/transpose.rs
Stefan Holderbach 9da0f41ebb Fix easy clippy lints from latest stable (#16053)
1.88.0 was released today, clippy now lints (machine-applicable)
against:
- format strings with empty braces that could be inlined
  - easy win
- `manual_abs_diff`
- returning of a stored result of the last expression.
  - this can be somewhat contentious but touched only a few places
2025-06-29 17:37:17 +02:00

43 lines
1.0 KiB
Rust

use nu_test_support::nu;
#[test]
fn row() {
let actual = nu!("[[key value]; [foo 1] [foo 2]] | transpose -r | debug");
assert!(actual.out.contains("foo: 1"));
}
#[test]
fn row_but_last() {
let actual = nu!("[[key value]; [foo 1] [foo 2]] | transpose -r -l | debug");
assert!(actual.out.contains("foo: 2"));
}
#[test]
fn row_but_all() {
let actual = nu!("[[key value]; [foo 1] [foo 2]] | transpose -r -a | debug");
assert!(actual.out.contains("foo: [1, 2]"));
}
#[test]
fn throw_inner_error() {
let error_msg = "This message should show up";
let error = format!("(error make {{ msg: \"{error_msg}\" }})");
let actual = nu!(format!(
"[[key value]; [foo 1] [foo 2] [{} 3]] | transpose",
error
));
assert!(actual.err.contains(error.as_str()));
}
#[test]
fn rejects_non_table_stream_input() {
let actual = nu!("[1 2 3] | each { |it| ($it * 2) } | transpose | to nuon");
assert!(actual.out.is_empty());
assert!(actual.err.contains("only table"));
}