mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
More readable tests.
This commit is contained in:
parent
610a91a658
commit
0893f89e89
3 changed files with 52 additions and 27 deletions
|
@ -153,7 +153,11 @@ fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
||||||
fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() {
|
fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() {
|
||||||
let (playground_path, _) = h::setup_playground_for("cp_test_3");
|
let (playground_path, _) = h::setup_playground_for("cp_test_3");
|
||||||
|
|
||||||
nu_error!(output, cwd(&playground_path), "cp ../formats cp_test_3");
|
nu_error!(
|
||||||
|
output,
|
||||||
|
cwd(&playground_path),
|
||||||
|
"cp ../formats cp_test_3"
|
||||||
|
);
|
||||||
|
|
||||||
assert!(output.contains("../formats"));
|
assert!(output.contains("../formats"));
|
||||||
assert!(output.contains("is a directory (not copied)"));
|
assert!(output.contains("is a directory (not copied)"));
|
||||||
|
@ -166,7 +170,11 @@ fn rm_can_remove_a_file() {
|
||||||
|
|
||||||
h::create_file_at(&file);
|
h::create_file_at(&file);
|
||||||
|
|
||||||
nu!(_output, cwd(directory), "rm rm_test.txt");
|
nu!(
|
||||||
|
_output,
|
||||||
|
cwd(directory),
|
||||||
|
"rm rm_test.txt"
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!h::file_exists_at(&file));
|
assert!(!h::file_exists_at(&file));
|
||||||
}
|
}
|
||||||
|
@ -185,10 +193,7 @@ fn rm_can_remove_directory_contents_with_recursive_flag() {
|
||||||
"rm rm_test --recursive"
|
"rm rm_test --recursive"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(!h::file_exists_at(&format!(
|
assert!(!h::file_exists_at(&format!("{}/{}", playground_path, tests_dir)));
|
||||||
"{}/{}",
|
|
||||||
playground_path, tests_dir
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -196,23 +201,36 @@ fn rm_error_if_attempting_to_delete_a_directory_without_recursive_flag() {
|
||||||
let (playground_path, tests_dir) = h::setup_playground_for("rm_test_2");
|
let (playground_path, tests_dir) = h::setup_playground_for("rm_test_2");
|
||||||
let full_path = format!("{}/{}", playground_path, tests_dir);
|
let full_path = format!("{}/{}", playground_path, tests_dir);
|
||||||
|
|
||||||
nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm rm_test_2");
|
nu_error!(
|
||||||
|
output,
|
||||||
|
cwd("tests/fixtures/nuplayground"),
|
||||||
|
"rm rm_test_2"
|
||||||
|
);
|
||||||
|
|
||||||
assert!(h::file_exists_at(&full_path));
|
assert!(h::file_exists_at(&full_path));
|
||||||
assert!(output.contains("is a directory"));
|
assert!(output.contains("is a directory"));
|
||||||
h::delete_directory_at(&full_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_error_if_attempting_to_delete_single_dot_as_argument() {
|
fn rm_error_if_attempting_to_delete_single_dot_as_argument() {
|
||||||
nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm .");
|
|
||||||
|
nu_error!(
|
||||||
|
output,
|
||||||
|
cwd("tests/fixtures/nuplayground"),
|
||||||
|
"rm ."
|
||||||
|
);
|
||||||
|
|
||||||
assert!(output.contains("may not be removed"));
|
assert!(output.contains("may not be removed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_error_if_attempting_to_delete_two_dot_as_argument() {
|
fn rm_error_if_attempting_to_delete_two_dot_as_argument() {
|
||||||
nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm ..");
|
|
||||||
|
nu_error!(
|
||||||
|
output,
|
||||||
|
cwd("tests/fixtures/nuplayground"),
|
||||||
|
"rm .."
|
||||||
|
);
|
||||||
|
|
||||||
assert!(output.contains("may not be removed"));
|
assert!(output.contains("may not be removed"));
|
||||||
}
|
}
|
|
@ -15,7 +15,8 @@ fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_convert_table_to_json_text_and_from_json_text_back_into_table() {
|
fn can_convert_table_to_json_text_and_from_json_text_back_into_table() {
|
||||||
nu!(output,
|
nu!(
|
||||||
|
output,
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"
|
"open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"
|
||||||
);
|
);
|
||||||
|
@ -47,7 +48,8 @@ fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_sort_by_column() {
|
fn can_sort_by_column() {
|
||||||
nu!(output,
|
nu!(
|
||||||
|
output,
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column \"=\" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it"
|
"open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column \"=\" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it"
|
||||||
);
|
);
|
||||||
|
@ -57,7 +59,8 @@ fn can_sort_by_column() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_split_by_column() {
|
fn can_split_by_column() {
|
||||||
nu!(output,
|
nu!(
|
||||||
|
output,
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it"
|
"open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it"
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,9 +15,11 @@ fn external_num() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inc_plugin() {
|
fn inc_plugin() {
|
||||||
nu!(output,
|
nu!(
|
||||||
|
output,
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | inc | echo $it");
|
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | inc | echo $it"
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(output, "11");
|
assert_eq!(output, "11");
|
||||||
}
|
}
|
||||||
|
@ -26,7 +28,8 @@ fn inc_plugin() {
|
||||||
fn add_plugin() {
|
fn add_plugin() {
|
||||||
nu!(output,
|
nu!(output,
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml | add dev-dependencies.newdep \"1\" | get dev-dependencies.newdep | echo $it");
|
"open cargo_sample.toml | add dev-dependencies.newdep \"1\" | get dev-dependencies.newdep | echo $it"
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(output, "1");
|
assert_eq!(output, "1");
|
||||||
}
|
}
|
||||||
|
@ -35,7 +38,8 @@ fn add_plugin() {
|
||||||
fn edit_plugin() {
|
fn edit_plugin() {
|
||||||
nu!(output,
|
nu!(output,
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml | edit dev-dependencies.pretty_assertions \"7\" | get dev-dependencies.pretty_assertions | echo $it");
|
"open cargo_sample.toml | edit dev-dependencies.pretty_assertions \"7\" | get dev-dependencies.pretty_assertions | echo $it"
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(output, "7");
|
assert_eq!(output, "7");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue