mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 17:39:15 +01:00
61455b457d
# Description This fixes up some clippy warnings and removes some old names/info from our unit tests # User-Facing Changes Internal changes only # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
131 lines
4.5 KiB
Rust
131 lines
4.5 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn moves_a_column_before() {
|
|
Playground::setup("move_column_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"sample.csv",
|
|
r#"
|
|
column1,column2,column3,...,column98,column99,column100
|
|
-------,-------,-------,---,--------, A ,---------
|
|
-------,-------,-------,---,--------, N ,---------
|
|
-------,-------,-------,---,--------, D ,---------
|
|
-------,-------,-------,---,--------, R ,---------
|
|
-------,-------,-------,---,--------, E ,---------
|
|
-------,-------,-------,---,--------, S ,---------
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample.csv
|
|
| move column99 --before column1
|
|
| rename chars
|
|
| get chars
|
|
| str trim
|
|
| str join
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("ANDRES"));
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn moves_columns_before() {
|
|
Playground::setup("move_column_test_2", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"sample.csv",
|
|
r#"
|
|
column1,column2,column3,...,column98,column99,column100
|
|
-------,-------, A ,---,--------, N ,---------
|
|
-------,-------, D ,---,--------, R ,---------
|
|
-------,-------, E ,---,--------, S ,---------
|
|
-------,-------, : ,---,--------, : ,---------
|
|
-------,-------, J ,---,--------, T ,---------
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample.csv
|
|
| move column99 column3 --before column2
|
|
| rename _ chars_1 chars_2
|
|
| select chars_2 chars_1
|
|
| upsert new_col {|f| $f | transpose | get column1 | str trim | str join}
|
|
| get new_col
|
|
| str join
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("ANDRES::JT"));
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn moves_a_column_after() {
|
|
Playground::setup("move_column_test_3", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"sample.csv",
|
|
r#"
|
|
column1,column2,letters,...,column98,and_more,column100
|
|
-------,-------, A ,---,--------, N ,---------
|
|
-------,-------, D ,---,--------, R ,---------
|
|
-------,-------, E ,---,--------, S ,---------
|
|
-------,-------, : ,---,--------, : ,---------
|
|
-------,-------, J ,---,--------, T ,---------
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample.csv
|
|
| move letters --after and_more
|
|
| move letters and_more --before column2
|
|
| rename _ chars_1 chars_2
|
|
| select chars_1 chars_2
|
|
| upsert new_col {|f| $f | transpose | get column1 | str trim | str join}
|
|
| get new_col
|
|
| str join
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("ANDRES::JT"));
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn moves_columns_after() {
|
|
Playground::setup("move_column_test_4", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"sample.csv",
|
|
r#"
|
|
column1,column2,letters,...,column98,and_more,column100
|
|
-------,-------, A ,---,--------, N ,---------
|
|
-------,-------, D ,---,--------, R ,---------
|
|
-------,-------, E ,---,--------, S ,---------
|
|
-------,-------, : ,---,--------, : ,---------
|
|
-------,-------, J ,---,--------, T ,---------
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample.csv
|
|
| move letters and_more --after column1
|
|
| columns
|
|
| select 1 2
|
|
| str join
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("lettersand_more"));
|
|
})
|
|
}
|