nushell/crates/nu-command/tests/commands/path/exists.rs
JT a008f1aa80
Command tests (#922)
* WIP command tests

* Finish marking todo tests

* update

* update

* Windows cd test ignoring
2022-02-03 21:01:45 -05:00

56 lines
1.2 KiB
Rust

use nu_test_support::fs::Stub::EmptyFile;
use nu_test_support::nu;
use nu_test_support::playground::Playground;
// FIXME: jt: needs more work
#[ignore]
#[test]
fn checks_if_existing_file_exists() {
Playground::setup("path_exists_1", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("spam.txt")]);
let actual = nu!(
cwd: dirs.test(),
"echo spam.txt | path exists"
);
assert_eq!(actual.out, "true");
})
}
#[test]
fn checks_if_missing_file_exists() {
Playground::setup("path_exists_2", |dirs, _| {
let actual = nu!(
cwd: dirs.test(),
"echo spam.txt | path exists"
);
assert_eq!(actual.out, "false");
})
}
#[test]
fn checks_if_dot_exists() {
Playground::setup("path_exists_3", |dirs, _| {
let actual = nu!(
cwd: dirs.test(),
"echo '.' | path exists"
);
assert_eq!(actual.out, "true");
})
}
#[test]
fn checks_if_double_dot_exists() {
Playground::setup("path_exists_4", |dirs, _| {
let actual = nu!(
cwd: dirs.test(),
"echo '..' | path exists"
);
assert_eq!(actual.out, "true");
})
}