2023-04-28 13:25:44 +02:00
|
|
|
use nu_test_support::nu;
|
2022-06-23 02:19:06 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn row() {
|
2023-04-28 13:25:44 +02:00
|
|
|
let actual = nu!("[[key value]; [foo 1] [foo 2]] | transpose -r | debug");
|
2022-06-23 02:19:06 +02:00
|
|
|
|
|
|
|
assert!(actual.out.contains("foo: 1"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn row_but_last() {
|
2023-04-28 13:25:44 +02:00
|
|
|
let actual = nu!("[[key value]; [foo 1] [foo 2]] | transpose -r -l | debug");
|
2022-06-23 02:19:06 +02:00
|
|
|
|
|
|
|
assert!(actual.out.contains("foo: 2"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn row_but_all() {
|
2023-04-28 13:25:44 +02:00
|
|
|
let actual = nu!("[[key value]; [foo 1] [foo 2]] | transpose -r -a | debug");
|
2022-06-23 02:19:06 +02:00
|
|
|
|
|
|
|
assert!(actual.out.contains("foo: [1, 2]"));
|
|
|
|
}
|
2024-10-22 18:30:48 +02:00
|
|
|
|
|
|
|
#[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()));
|
|
|
|
}
|