mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 18:37:42 +02:00
Command tests (#922)
* WIP command tests * Finish marking todo tests * update * update * Windows cd test ignoring
This commit is contained in:
37
crates/nu-command/tests/commands/nth.rs
Normal file
37
crates/nu-command/tests/commands/nth.rs
Normal file
@ -0,0 +1,37 @@
|
||||
#[test]
|
||||
fn selects_a_row() {
|
||||
Playground::setup("nth_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| sort-by name
|
||||
| nth 0
|
||||
| get name
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "arepas.txt");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selects_many_rows() {
|
||||
Playground::setup("nth_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls
|
||||
| get name
|
||||
| nth 1 0
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "2");
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user