mirror of
https://github.com/nushell/nushell.git
synced 2024-11-30 04:14:17 +01:00
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
|
use nu_test_support::nu;
|
||
|
use nu_test_support::playground::Playground;
|
||
|
use std::path::PathBuf;
|
||
|
|
||
|
#[test]
|
||
|
fn creates_temp_file() {
|
||
|
Playground::setup("mktemp_test_1", |dirs, _| {
|
||
|
let output = nu!(
|
||
|
cwd: dirs.test(),
|
||
|
"mktemp"
|
||
|
);
|
||
|
let loc = PathBuf::from(output.out.clone());
|
||
|
println!("{:?}", loc);
|
||
|
assert!(loc.exists());
|
||
|
})
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn creates_temp_file_with_suffix() {
|
||
|
Playground::setup("mktemp_test_2", |dirs, _| {
|
||
|
let output = nu!(
|
||
|
cwd: dirs.test(),
|
||
|
"mktemp --suffix .txt tempfileXXX"
|
||
|
);
|
||
|
let loc = PathBuf::from(output.out.clone());
|
||
|
assert!(loc.exists());
|
||
|
assert!(loc.is_file());
|
||
|
assert!(output.out.ends_with(".txt"));
|
||
|
assert!(output.out.starts_with(dirs.test().to_str().unwrap()));
|
||
|
})
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn creates_temp_directory() {
|
||
|
Playground::setup("mktemp_test_3", |dirs, _| {
|
||
|
let output = nu!(
|
||
|
cwd: dirs.test(),
|
||
|
"mktemp -d"
|
||
|
);
|
||
|
|
||
|
let loc = PathBuf::from(output.out);
|
||
|
assert!(loc.exists());
|
||
|
assert!(loc.is_dir());
|
||
|
})
|
||
|
}
|