mirror of
https://github.com/nushell/nushell.git
synced 2024-12-18 05:02:06 +01:00
656f707a0b
# Description The working directory doesn't have to be set for those tests (or would be the default anyways). When appropriate also remove calls to the `pipeline()` function. In most places kept the diff minimal and only removed the superfluous part to not pollute the blame view. With simpler tests also simplified things to make them more readable overall (this included removal of the raw string literal). Work for #8670
60 lines
1.3 KiB
Rust
60 lines
1.3 KiB
Rust
use nu_test_support::fs::Stub::EmptyFile;
|
|
use nu_test_support::nu;
|
|
use nu_test_support::playground::Playground;
|
|
|
|
#[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");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn checks_tilde_relative_path_exists() {
|
|
let actual = nu!("'~' | path exists");
|
|
assert_eq!(actual.out, "true");
|
|
}
|