Improve tests and labeling in FilesystemShell (#1305)

Additional `ls` command tests and better FilesystemShell error and label messages.
This commit is contained in:
Jason Gedge
2020-02-01 03:34:34 -05:00
committed by GitHub
parent 9474fa1ea5
commit dcdfa2a866
3 changed files with 96 additions and 126 deletions

View File

@ -1,6 +1,6 @@
use nu_test_support::fs::Stub::EmptyFile;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
use nu_test_support::{nu, nu_error, pipeline};
#[test]
fn lists_regular_files() {
@ -99,3 +99,35 @@ fn lists_all_files_in_directories_from_stream() {
assert_eq!(actual, "4");
})
}
#[test]
fn does_not_fail_if_glob_matches_empty_directory() {
Playground::setup("ls_test_5", |dirs, sandbox| {
sandbox.within("dir_a");
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls dir_a
| count
| echo $it
"#
));
assert_eq!(actual, "0");
})
}
#[test]
fn fails_when_glob_doesnt_match() {
Playground::setup("ls_test_5", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("root1.txt"), EmptyFile("root2.txt")]);
let actual = nu_error!(
cwd: dirs.test(),
"ls root3*"
);
assert!(actual.contains("invalid file or pattern"));
})
}

View File

@ -132,7 +132,7 @@ fn errors_if_attempting_to_delete_a_directory_with_content_without_recursive_fla
);
assert!(dirs.test().exists());
assert!(actual.contains("Cannot remove non-empty directory"));
assert!(actual.contains("cannot remove non-empty directory"));
})
}