Extract tests.

This commit is contained in:
Andrés N. Robalino
2019-08-10 04:11:38 -05:00
parent cb4b2e6116
commit 5372463b37
3 changed files with 75 additions and 61 deletions

58
tests/filter_str_tests.rs Normal file
View File

@ -0,0 +1,58 @@
mod helpers;
use helpers::in_directory as cwd;
#[test]
fn acts_without_passing_field() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | first 1 | get origin | str --downcase | echo $it"
);
assert_eq!(output, "spain");
}
#[test]
fn str_can_only_apply_one() {
nu_error!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | first 1 | str origin --downcase --upcase"
);
assert!(output.contains("Usage: str field [--downcase|--upcase|--to-int]"));
}
#[test]
fn downcases() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | first 1 | str origin --downcase | get origin | echo $it"
);
assert_eq!(output, "spain");
}
#[test]
fn upcases() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open appveyor.yml | str environment.global.PROJECT_NAME --upcase | get environment.global.PROJECT_NAME | echo $it"
);
assert_eq!(output, "NUSHELL");
}
#[test]
fn converts_to_int() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | get 0 | str tariff_item --to-int | where tariff_item == 2509000000 | get tariff_item | echo $it"
);
assert_eq!(output, "2509000000");
}

View File

@ -68,50 +68,6 @@ fn can_split_by_column() {
assert_eq!(output, "name");
}
#[test]
fn str_can_only_apply_one() {
nu_error!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | first 1 | str origin --downcase --upcase"
);
assert!(output.contains("Usage: str field [--downcase|--upcase|--to-int]"));
}
#[test]
fn str_downcases() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | first 1 | str origin --downcase | get origin | echo $it"
);
assert_eq!(output, "spain");
}
#[test]
fn str_upcases() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open appveyor.yml | str environment.global.PROJECT_NAME --upcase | get environment.global.PROJECT_NAME | echo $it"
);
assert_eq!(output, "NUSHELL");
}
#[test]
fn str_converts_to_int() {
nu!(
output,
cwd("tests/fixtures/formats"),
"open caco3_plastics.csv | first 1 | str tariff_item --to-int | where tariff_item == 2509000000 | get tariff_item | echo $it"
);
assert_eq!(output, "2509000000");
}
#[test]
fn can_sum() {
nu!(
@ -122,6 +78,7 @@ fn can_sum() {
assert_eq!(output, "203")
}
#[test]
fn can_filter_by_unit_size_comparison() {
nu!(