nushell/tests/command_ls_tests.rs

73 lines
1.6 KiB
Rust
Raw Normal View History

2019-08-02 09:23:39 +00:00
mod helpers;
use helpers as h;
2019-08-29 06:31:56 +00:00
use helpers::{Playground, Stub::*};
2019-08-02 09:23:39 +00:00
#[test]
fn ls_lists_regular_files() {
2019-08-29 00:32:42 +00:00
Playground::setup("ls_test_1", |dirs, sandbox| {
2019-09-11 14:36:50 +00:00
sandbox.with_files(vec![
EmptyFile("yehuda.txt"),
EmptyFile("jonathan.txt"),
EmptyFile("andres.txt"),
2019-08-29 00:32:42 +00:00
]);
2019-08-02 09:23:39 +00:00
2019-08-29 00:32:42 +00:00
let actual = nu!(
2019-08-29 06:31:56 +00:00
cwd: dirs.test(), h::pipeline(
r#"
ls
| count
2019-08-29 06:31:56 +00:00
| echo $it
"#
2019-08-29 00:32:42 +00:00
));
2019-08-02 09:23:39 +00:00
assert_eq!(actual, "3");
})
2019-08-02 09:23:39 +00:00
}
#[test]
fn ls_lists_regular_files_using_asterisk_wildcard() {
2019-08-29 00:32:42 +00:00
Playground::setup("ls_test_2", |dirs, sandbox| {
2019-09-11 14:36:50 +00:00
sandbox.with_files(vec![
EmptyFile("los.txt"),
EmptyFile("tres.txt"),
EmptyFile("amigos.txt"),
EmptyFile("arepas.clu"),
2019-08-29 00:32:42 +00:00
]);
2019-08-02 09:23:39 +00:00
2019-08-29 00:32:42 +00:00
let actual = nu!(
2019-08-29 06:31:56 +00:00
cwd: dirs.test(), h::pipeline(
r#"
ls *.txt
| count
2019-08-29 06:31:56 +00:00
| echo $it
"#
2019-08-29 00:32:42 +00:00
));
2019-08-02 09:23:39 +00:00
2019-08-29 00:32:42 +00:00
assert_eq!(actual, "3");
})
2019-08-02 09:23:39 +00:00
}
#[test]
fn ls_lists_regular_files_using_question_mark_wildcard() {
2019-08-29 00:32:42 +00:00
Playground::setup("ls_test_3", |dirs, sandbox| {
2019-09-11 14:36:50 +00:00
sandbox.with_files(vec![
EmptyFile("yehuda.10.txt"),
EmptyFile("jonathan.10.txt"),
EmptyFile("andres.10.txt"),
EmptyFile("chicken_not_to_be_picked_up.100.txt"),
2019-08-29 00:32:42 +00:00
]);
2019-08-02 09:23:39 +00:00
2019-08-29 00:32:42 +00:00
let actual = nu!(
2019-08-29 06:31:56 +00:00
cwd: dirs.test(), h::pipeline(
r#"
ls *.??.txt
| count
2019-08-29 06:31:56 +00:00
| echo $it
"#
2019-08-29 00:32:42 +00:00
));
2019-08-02 09:23:39 +00:00
assert_eq!(actual, "3");
})
2019-08-02 09:23:39 +00:00
}