2019-08-07 02:45:38 +00:00
|
|
|
mod helpers;
|
|
|
|
|
|
|
|
use h::{in_directory as cwd, Playground};
|
|
|
|
use helpers as h;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn creates_directory() {
|
|
|
|
let sandbox = Playground::setup_for("mkdir_test").test_dir_name();
|
|
|
|
|
|
|
|
let full_path = format!("{}/{}", Playground::root(), sandbox);
|
|
|
|
|
|
|
|
nu!(_output, cwd(&full_path), "mkdir my_new_directory");
|
|
|
|
|
|
|
|
let mut expected = PathBuf::from(full_path);
|
|
|
|
expected.push("my_new_directory");
|
|
|
|
|
|
|
|
assert!(h::dir_exists_at(expected));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2019-08-07 19:38:00 +00:00
|
|
|
fn creates_intermediary_directories() {
|
2019-08-07 02:45:38 +00:00
|
|
|
let sandbox = Playground::setup_for("mkdir_test_2").test_dir_name();
|
|
|
|
|
|
|
|
let full_path = format!("{}/{}", Playground::root(), sandbox);
|
|
|
|
|
|
|
|
nu!(
|
|
|
|
_output,
|
|
|
|
cwd(&full_path),
|
2019-08-07 19:38:00 +00:00
|
|
|
"mkdir some_folder/another/deeper_one"
|
2019-08-07 02:45:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
let mut expected = PathBuf::from(full_path);
|
|
|
|
expected.push("some_folder/another/deeper_one");
|
|
|
|
|
|
|
|
assert!(h::dir_exists_at(expected));
|
|
|
|
}
|