2019-08-07 04:45:38 +02:00
|
|
|
mod helpers;
|
|
|
|
|
|
|
|
use h::{in_directory as cwd, Playground};
|
|
|
|
use helpers as h;
|
2019-08-21 14:07:37 +02:00
|
|
|
use std::path::{Path, PathBuf};
|
2019-08-07 04:45:38 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn creates_directory() {
|
2019-08-14 22:07:08 +02:00
|
|
|
let sandbox = Playground::setup_for("mkdir_test_1").test_dir_name();
|
2019-08-07 04:45:38 +02:00
|
|
|
|
|
|
|
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-21 14:07:37 +02:00
|
|
|
fn accepts_and_creates_directories() {
|
2019-08-07 04:45:38 +02:00
|
|
|
let sandbox = Playground::setup_for("mkdir_test_2").test_dir_name();
|
|
|
|
|
|
|
|
let full_path = format!("{}/{}", Playground::root(), sandbox);
|
|
|
|
|
2019-08-21 14:07:37 +02:00
|
|
|
nu!(_output, cwd(&full_path), "mkdir dir_1 dir_2 dir_3");
|
|
|
|
|
|
|
|
assert!(h::files_exist_at(
|
|
|
|
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
|
|
|
PathBuf::from(&full_path)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn creates_intermediary_directories() {
|
|
|
|
let sandbox = Playground::setup_for("mkdir_test_3").test_dir_name();
|
|
|
|
|
|
|
|
let full_path = format!("{}/{}", Playground::root(), sandbox);
|
|
|
|
|
2019-08-07 04:45:38 +02:00
|
|
|
nu!(
|
|
|
|
_output,
|
|
|
|
cwd(&full_path),
|
2019-08-07 21:38:00 +02:00
|
|
|
"mkdir some_folder/another/deeper_one"
|
2019-08-07 04:45:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let mut expected = PathBuf::from(full_path);
|
|
|
|
expected.push("some_folder/another/deeper_one");
|
|
|
|
|
|
|
|
assert!(h::dir_exists_at(expected));
|
|
|
|
}
|