2019-07-16 12:28:55 +02:00
|
|
|
mod helpers;
|
|
|
|
|
|
|
|
use helpers::in_directory as cwd;
|
|
|
|
|
2019-07-21 09:08:05 +02:00
|
|
|
#[test]
|
|
|
|
fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() {
|
2019-07-26 20:40:00 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-07-21 09:08:05 +02:00
|
|
|
cwd("tests/fixtures/formats"),
|
2019-07-22 04:23:02 +02:00
|
|
|
"open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it"
|
|
|
|
);
|
2019-07-21 09:08:05 +02:00
|
|
|
|
|
|
|
assert_eq!(output, "SPAIN");
|
|
|
|
}
|
|
|
|
|
2019-07-16 12:28:55 +02:00
|
|
|
#[test]
|
|
|
|
fn can_convert_table_to_json_text_and_from_json_text_back_into_table() {
|
2019-08-01 11:25:48 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-07-16 12:28:55 +02:00
|
|
|
cwd("tests/fixtures/formats"),
|
2019-07-22 04:23:02 +02:00
|
|
|
"open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"
|
|
|
|
);
|
2019-07-16 12:28:55 +02:00
|
|
|
|
|
|
|
assert_eq!(output, "markup");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn can_convert_table_to_toml_text_and_from_toml_text_back_into_table() {
|
2019-07-17 19:51:53 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-07-16 12:28:55 +02:00
|
|
|
cwd("tests/fixtures/formats"),
|
2019-07-17 19:51:53 +02:00
|
|
|
"open cargo_sample.toml | to-toml | from-toml | get package.name | echo $it"
|
|
|
|
);
|
2019-07-16 12:28:55 +02:00
|
|
|
|
|
|
|
assert_eq!(output, "nu");
|
|
|
|
}
|
|
|
|
|
2019-07-17 19:51:53 +02:00
|
|
|
#[test]
|
|
|
|
fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() {
|
|
|
|
nu!(
|
|
|
|
output,
|
|
|
|
cwd("tests/fixtures/formats"),
|
|
|
|
"open appveyor.yml | to-yaml | from-yaml | get environment.global.PROJECT_NAME | echo $it"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(output, "nushell");
|
|
|
|
}
|
|
|
|
|
2019-07-16 12:28:55 +02:00
|
|
|
#[test]
|
|
|
|
fn can_sort_by_column() {
|
2019-08-01 11:25:48 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-07-16 12:28:55 +02:00
|
|
|
cwd("tests/fixtures/formats"),
|
2019-07-22 04:23:02 +02:00
|
|
|
"open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column \"=\" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it"
|
|
|
|
);
|
2019-07-16 12:28:55 +02:00
|
|
|
|
|
|
|
assert_eq!(output, "description");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn can_split_by_column() {
|
2019-08-01 11:25:48 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-07-16 12:28:55 +02:00
|
|
|
cwd("tests/fixtures/formats"),
|
2019-07-22 04:23:02 +02:00
|
|
|
"open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it"
|
|
|
|
);
|
2019-07-16 12:28:55 +02:00
|
|
|
|
|
|
|
assert_eq!(output, "name");
|
|
|
|
}
|
|
|
|
|
2019-07-26 20:40:00 +02:00
|
|
|
#[test]
|
|
|
|
fn can_sum() {
|
|
|
|
nu!(
|
|
|
|
output,
|
|
|
|
cwd("tests/fixtures/formats"),
|
|
|
|
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Sections | sum | echo $it"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(output, "203")
|
|
|
|
}
|
2019-08-10 11:11:38 +02:00
|
|
|
|
2019-07-16 12:28:55 +02:00
|
|
|
#[test]
|
|
|
|
fn can_filter_by_unit_size_comparison() {
|
2019-07-17 19:51:53 +02:00
|
|
|
nu!(
|
|
|
|
output,
|
2019-07-16 12:28:55 +02:00
|
|
|
cwd("tests/fixtures/formats"),
|
2019-08-08 19:53:28 +02:00
|
|
|
"ls | where size > 1kb | sort-by size | get name | skip 1 | trim | echo $it"
|
2019-07-17 19:51:53 +02:00
|
|
|
);
|
2019-07-16 12:28:55 +02:00
|
|
|
|
2019-08-08 19:53:28 +02:00
|
|
|
assert_eq!(output, "caco3_plastics.csv");
|
2019-07-16 12:28:55 +02:00
|
|
|
}
|