2019-12-15 17:15:06 +01:00
|
|
|
#[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
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 13:03:43 +02:00
|
|
|
assert_eq!(actual.out, "arepas.txt");
|
2019-12-15 17:15:06 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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
|
|
|
|
| count
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 13:03:43 +02:00
|
|
|
assert_eq!(actual.out, "2");
|
2019-12-15 17:15:06 +01:00
|
|
|
});
|
2020-10-26 07:55:52 +01:00
|
|
|
}
|