mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 15:28:53 +02:00
Extract tests.
This commit is contained in:
58
tests/filter_str_tests.rs
Normal file
58
tests/filter_str_tests.rs
Normal 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");
|
||||
}
|
@ -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!(
|
||||
|
Reference in New Issue
Block a user