Split split command to sub commands.

This commit is contained in:
Andrés N. Robalino
2020-05-24 01:41:30 -05:00
parent 74c2daf665
commit edbecda14d
22 changed files with 154 additions and 57 deletions

View File

@ -1,20 +1,30 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn by_column() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open cargo_sample.toml --raw
| lines
| skip 1
| first 1
| split-column "="
| get Column1
| trim
| echo $it
"#
));
fn to_column() {
Playground::setup("split_column_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"sample.txt",
r#"
importer,shipper,tariff_item,name,origin
"#,
)]);
assert_eq!(actual.out, "name");
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open sample.txt
| lines
| trim
| split column ","
| pivot
| nth 1
| echo $it
"#
));
assert!(actual.out.contains("shipper"));
})
}