mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Command tests (#922)
* WIP command tests * Finish marking todo tests * update * update * Windows cd test ignoring
This commit is contained in:
85
crates/nu-command/tests/commands/rotate.rs
Normal file
85
crates/nu-command/tests/commands/rotate.rs
Normal file
@ -0,0 +1,85 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn counter_clockwise() {
|
||||
let table = pipeline(
|
||||
r#"
|
||||
echo [
|
||||
[col1, col2, EXPECTED];
|
||||
|
||||
[---, "|||", XX1]
|
||||
[---, "|||", XX2]
|
||||
[---, "|||", XX3]
|
||||
]
|
||||
"#,
|
||||
);
|
||||
|
||||
let expected = nu!(cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [
|
||||
[ Column0, Column1, Column2, Column3];
|
||||
|
||||
[ EXPECTED, XX1, XX2, XX3]
|
||||
[ col2, "|||", "|||", "|||"]
|
||||
[ col1, ---, ---, ---]
|
||||
]
|
||||
| where Column0 == EXPECTED
|
||||
| get Column1 Column2 Column3
|
||||
| str collect "-"
|
||||
"#,
|
||||
));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
format!("{} | {}", table, pipeline(r#"
|
||||
rotate counter-clockwise
|
||||
| where Column0 == EXPECTED
|
||||
| get Column1 Column2 Column3
|
||||
| str collect "-"
|
||||
"#)));
|
||||
|
||||
assert_eq!(actual.out, expected.out);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clockwise() {
|
||||
let table = pipeline(
|
||||
r#"
|
||||
echo [
|
||||
[col1, col2, EXPECTED];
|
||||
|
||||
[ ---, "|||", XX1]
|
||||
[ ---, "|||", XX2]
|
||||
[ ---, "|||", XX3]
|
||||
]
|
||||
"#,
|
||||
);
|
||||
|
||||
let expected = nu!(cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [
|
||||
[ Column0, Column1, Column2, Column3];
|
||||
|
||||
[ ---, ---, ---, col1]
|
||||
[ "|||", "|||", "|||", col2]
|
||||
[ XX3, XX2, XX1, EXPECTED]
|
||||
]
|
||||
| where Column3 == EXPECTED
|
||||
| get Column0 Column1 Column2
|
||||
| str collect "-"
|
||||
"#,
|
||||
));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
format!("{} | {}", table, pipeline(r#"
|
||||
rotate
|
||||
| where Column3 == EXPECTED
|
||||
| get Column0 Column1 Column2
|
||||
| str collect "-"
|
||||
"#)));
|
||||
|
||||
assert_eq!(actual.out, expected.out);
|
||||
}
|
Reference in New Issue
Block a user