Yo quiero Playground taconushell.

This commit is contained in:
Andrés N. Robalino
2019-08-28 19:32:42 -05:00
parent f82cc4291f
commit 55fb1f8dda
14 changed files with 698 additions and 540 deletions

View File

@ -3,20 +3,17 @@ mod helpers;
use h::{in_directory as cwd, Playground, Stub::*};
use helpers as h;
use std::path::{Path, PathBuf};
#[test]
fn moves_a_file() {
Playground::setup("mv_test_1", |dirs, playground| {
playground
Playground::setup("mv_test_1", |dirs, sandbox| {
sandbox
.with_files(vec![EmptyFile("andres.txt")])
.mkdir("expected")
.test_dir_name();
.mkdir("expected");
let original = dirs.test().join("andres.txt");
let expected = dirs.test().join("expected/yehuda.txt");
nu!(dirs.test(), "mv andres.txt expected/yehuda.txt");
nu!(cwd(dirs.test()), "mv andres.txt expected/yehuda.txt");
assert!(!h::file_exists_at(original));
assert!(h::file_exists_at(expected));
@ -25,15 +22,17 @@ fn moves_a_file() {
#[test]
fn overwrites_if_moving_to_existing_file() {
Playground::setup("mv_test_2", |dirs, playground| {
playground
.with_files(vec![EmptyFile("andres.txt"), EmptyFile("jonathan.txt")])
.test_dir_name();
Playground::setup("mv_test_2", |dirs, sandbox| {
sandbox
.with_files(vec![
EmptyFile("andres.txt"),
EmptyFile("jonathan.txt")
]);
let original = dirs.test().join("andres.txt");
let expected = dirs.test().join("jonathan.txt");
nu!(dirs.test(), "mv andres.txt jonathan.txt");
nu!(cwd(dirs.test()), "mv andres.txt jonathan.txt");
assert!(!h::file_exists_at(original));
assert!(h::file_exists_at(expected));
@ -42,13 +41,13 @@ fn overwrites_if_moving_to_existing_file() {
#[test]
fn moves_a_directory() {
Playground::setup("mv_test_3", |dirs, playground| {
playground.mkdir("empty_dir");
Playground::setup("mv_test_3", |dirs, sandbox| {
sandbox.mkdir("empty_dir");
let original_dir = dirs.test().join("empty_dir");
let expected = dirs.test().join("renamed_dir");
nu!(dirs.test(), "mv empty_dir renamed_dir");
nu!(cwd(dirs.test()), "mv empty_dir renamed_dir");
assert!(!h::dir_exists_at(original_dir));
assert!(h::dir_exists_at(expected));
@ -57,11 +56,10 @@ fn moves_a_directory() {
#[test]
fn moves_the_file_inside_directory_if_path_to_move_is_existing_directory() {
Playground::setup("mv_test_4", |dirs, playground| {
playground
Playground::setup("mv_test_4", |dirs, sandbox| {
sandbox
.with_files(vec![EmptyFile("jonathan.txt")])
.mkdir("expected")
.test_dir_name();
.mkdir("expected");
let original_dir = dirs.test().join("jonathan.txt");
let expected = dirs.test().join("expected/jonathan.txt");
@ -75,12 +73,11 @@ fn moves_the_file_inside_directory_if_path_to_move_is_existing_directory() {
#[test]
fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory() {
Playground::setup("mv_test_5", |dirs, playground| {
playground
Playground::setup("mv_test_5", |dirs, sandbox| {
sandbox
.within("contributors")
.with_files(vec![EmptyFile("jonathan.txt")])
.mkdir("expected")
.test_dir_name();
.mkdir("expected");
let original_dir = dirs.test().join("contributors");
let expected = dirs.test().join("expected/contributors");
@ -94,17 +91,16 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory()
#[test]
fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory() {
Playground::setup("mv_test_6", |dirs, playground| {
playground
Playground::setup("mv_test_6", |dirs, sandbox| {
sandbox
.within("contributors")
.with_files(vec![EmptyFile("jonathan.txt")])
.mkdir("expected")
.test_dir_name();
.mkdir("expected");
let original_dir = dirs.test().join("contributors");
nu!(
dirs.test(),
cwd(dirs.test()),
"mv contributors expected/this_dir_exists_now/los_tres_amigos"
);
@ -119,8 +115,8 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory
#[test]
fn moves_using_path_with_wildcard() {
Playground::setup("mv_test_7", |dirs, playground| {
playground
Playground::setup("mv_test_7", |dirs, sandbox| {
sandbox
.within("originals")
.with_files(vec![
EmptyFile("andres.ini"),
@ -131,16 +127,15 @@ fn moves_using_path_with_wildcard() {
EmptyFile("sgml_description.json"),
EmptyFile("sample.ini"),
EmptyFile("utf16.ini"),
EmptyFile("yehuda.ini"),
EmptyFile("yehuda.ini")
])
.mkdir("work_dir")
.mkdir("expected")
.test_dir_name();
.mkdir("expected");
let work_dir = dirs.test().join("work_dir");
let expected = dirs.test().join("expected");
nu!(work_dir, "mv ../originals/*.ini ../expected");
nu!(cwd(work_dir), "mv ../originals/*.ini ../expected");
assert!(h::files_exist_at(
vec!["yehuda.ini", "jonathan.ini", "sample.ini", "andres.ini",],
@ -151,23 +146,22 @@ fn moves_using_path_with_wildcard() {
#[test]
fn moves_using_a_glob() {
Playground::setup("mv_test_8", |dirs, playground| {
playground
Playground::setup("mv_test_8", |dirs, sandbox| {
sandbox
.within("meals")
.with_files(vec![
EmptyFile("arepa.txt"),
EmptyFile("empanada.txt"),
EmptyFile("taquiza.txt"),
EmptyFile("taquiza.txt")
])
.mkdir("work_dir")
.mkdir("expected")
.test_dir_name();
.mkdir("expected");
let meal_dir = dirs.test().join("meals");
let work_dir = dirs.test().join("work_dir");
let expected = dirs.test().join("expected");
nu!(work_dir, "mv ../meals/* ../expected");
nu!(cwd(work_dir), "mv ../meals/* ../expected");
assert!(h::dir_exists_at(meal_dir));
assert!(h::files_exist_at(