forked from extern/nushell
b2c5af457e
This improves incremental build time when working on what was previously the root package. For example, previously all plugins would be rebuilt with a change to `src/commands/classified/external.rs`, but now only `nu-cli` will have to be rebuilt (and anything that depends on it).
48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
use nu_test_support::fs::Stub::EmptyFile;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn selects_a_row() {
|
|
Playground::setup("range_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("tests.txt")]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
ls
|
|
| sort-by name
|
|
| range 0..0
|
|
| get name
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "notes.txt");
|
|
});
|
|
}
|
|
|
|
#[test]
|
|
fn selects_some_rows() {
|
|
Playground::setup("range_test_2", |dirs, sandbox| {
|
|
sandbox.with_files(vec![
|
|
EmptyFile("notes.txt"),
|
|
EmptyFile("tests.txt"),
|
|
EmptyFile("persons.txt"),
|
|
]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
ls
|
|
| get name
|
|
| range 1..2
|
|
| count
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "2");
|
|
});
|
|
}
|