2020-11-24 10:18:38 +01:00
|
|
|
use nu_test_support::fs::Stub::EmptyFile;
|
|
|
|
use nu_test_support::playground::Playground;
|
|
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn returns_type_of_missing_file() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: "tests", pipeline(
|
|
|
|
r#"
|
2022-02-21 14:38:15 +01:00
|
|
|
echo "spam.txt"
|
2020-11-24 10:18:38 +01:00
|
|
|
| path type
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual.out, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn returns_type_of_existing_file() {
|
|
|
|
Playground::setup("path_expand_1", |dirs, sandbox| {
|
|
|
|
sandbox
|
|
|
|
.within("menu")
|
|
|
|
.with_files(vec![EmptyFile("spam.txt")]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), pipeline(
|
|
|
|
r#"
|
2022-02-21 14:38:15 +01:00
|
|
|
echo "menu"
|
2020-11-24 10:18:38 +01:00
|
|
|
| path type
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2022-02-04 03:01:45 +01:00
|
|
|
assert_eq!(actual.out, "dir");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-24 10:18:38 +01:00
|
|
|
#[test]
|
|
|
|
fn returns_type_of_existing_directory() {
|
|
|
|
Playground::setup("path_expand_1", |dirs, sandbox| {
|
|
|
|
sandbox
|
|
|
|
.within("menu")
|
|
|
|
.with_files(vec![EmptyFile("spam.txt")]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), pipeline(
|
|
|
|
r#"
|
2022-02-21 14:38:15 +01:00
|
|
|
echo "menu/spam.txt"
|
2020-11-24 10:18:38 +01:00
|
|
|
| path type
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2022-02-04 03:01:45 +01:00
|
|
|
assert_eq!(actual.out, "file");
|
2020-11-24 10:18:38 +01:00
|
|
|
})
|
|
|
|
}
|