mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:27:44 +02:00
Yo quiero Playground taconushell.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
mod helpers;
|
||||
|
||||
use helpers::{dir_exists_at, file_exists_at, files_exist_at, Playground, Stub::*};
|
||||
|
||||
use helpers::{in_directory as cwd, dir_exists_at, file_exists_at, files_exist_at, Playground, Stub::*};
|
||||
use nu::AbsoluteFile;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@ -9,7 +8,7 @@ use std::path::{Path, PathBuf};
|
||||
fn copies_a_file() {
|
||||
Playground::setup("cp_test_1", |dirs, _| {
|
||||
nu!(
|
||||
dirs.root(),
|
||||
cwd(dirs.root()),
|
||||
"cp {} cp_test_1/sample.ini",
|
||||
dirs.formats().join("sample.ini")
|
||||
);
|
||||
@ -24,7 +23,7 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
||||
let expected_file = AbsoluteFile::new(dirs.test().join("sample.ini"));
|
||||
|
||||
nu!(
|
||||
dirs.formats(),
|
||||
cwd(dirs.formats()),
|
||||
"cp ../formats/sample.ini {}",
|
||||
expected_file.dir()
|
||||
);
|
||||
@ -36,17 +35,17 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
||||
#[test]
|
||||
fn error_if_attempting_to_copy_a_directory_to_another_directory() {
|
||||
Playground::setup("cp_test_3", |dirs, _| {
|
||||
let output = nu_error!(dirs.formats(), "cp ../formats {}", dirs.test());
|
||||
let actual = nu_error!(dirs.formats(), "cp ../formats {}", dirs.test());
|
||||
|
||||
assert!(output.contains("../formats"));
|
||||
assert!(output.contains("is a directory (not copied)"));
|
||||
assert!(actual.contains("../formats"));
|
||||
assert!(actual.contains("is a directory (not copied)"));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_recursive_flag() {
|
||||
Playground::setup("cp_test_4", |dirs, playground| {
|
||||
playground
|
||||
Playground::setup("cp_test_4", |dirs, sandbox| {
|
||||
sandbox
|
||||
.within("originals")
|
||||
.with_files(vec![
|
||||
EmptyFile("yehuda.txt"),
|
||||
@ -57,7 +56,7 @@ fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_r
|
||||
|
||||
let expected_dir = dirs.test().join("expected").join("originals");
|
||||
|
||||
nu!(dirs.test(), "cp originals expected --recursive");
|
||||
nu!(cwd(dirs.test()), "cp originals expected --recursive");
|
||||
|
||||
assert!(dir_exists_at(PathBuf::from(&expected_dir)));
|
||||
assert!(files_exist_at(
|
||||
@ -91,8 +90,8 @@ fn deep_copies_with_recursive_flag() {
|
||||
originals/contributors/yehuda/defer-evaluation.txt
|
||||
"#;
|
||||
|
||||
Playground::setup("cp_test_5", |dirs, playground| {
|
||||
playground
|
||||
Playground::setup("cp_test_5", |dirs, sandbox| {
|
||||
sandbox
|
||||
.within("originals")
|
||||
.with_files(vec![EmptyFile("manifest.txt")])
|
||||
.within("originals/contributors")
|
||||
@ -115,7 +114,7 @@ fn deep_copies_with_recursive_flag() {
|
||||
let andres_expected_copied_dir = expected_dir.join("contributors").join("andres");
|
||||
let yehudas_expected_copied_dir = expected_dir.join("contributors").join("yehuda");
|
||||
|
||||
nu!(dirs.test(), "cp originals expected --recursive");
|
||||
nu!(cwd(dirs.test()), "cp originals expected --recursive");
|
||||
|
||||
assert!(dir_exists_at(PathBuf::from(&expected_dir)));
|
||||
assert!(files_exist_at(
|
||||
@ -136,7 +135,7 @@ fn deep_copies_with_recursive_flag() {
|
||||
#[test]
|
||||
fn copies_using_path_with_wildcard() {
|
||||
Playground::setup("cp_test_6", |dirs, _| {
|
||||
nu!(dirs.formats(), "cp ../formats/* {}", dirs.test());
|
||||
nu!(cwd(dirs.formats()), "cp ../formats/* {}", dirs.test());
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
@ -155,7 +154,7 @@ fn copies_using_path_with_wildcard() {
|
||||
#[test]
|
||||
fn copies_using_a_glob() {
|
||||
Playground::setup("cp_test_7", |dirs, _| {
|
||||
nu!(dirs.formats(), "cp * {}", dirs.test());
|
||||
nu!(cwd(dirs.formats()), "cp * {}", dirs.test());
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
|
Reference in New Issue
Block a user