forked from extern/nushell
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.
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn discards_rows_where_given_column_is_empty() {
|
|
Playground::setup("compact_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"los_tres_amigos.json",
|
|
r#"
|
|
{
|
|
"amigos": [
|
|
{"name": "Yehuda", "rusty_luck": 1},
|
|
{"name": "JT", "rusty_luck": 1},
|
|
{"name": "Andres", "rusty_luck": 1},
|
|
{"name":"GorbyPuff"}
|
|
]
|
|
}
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open los_tres_amigos.json
|
|
| get amigos
|
|
| compact rusty_luck
|
|
| length
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "3");
|
|
});
|
|
}
|
|
#[test]
|
|
fn discards_empty_rows_by_default() {
|
|
Playground::setup("compact_test_2", |dirs, _| {
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
echo "[1,2,3,14,null]"
|
|
| from json
|
|
| compact
|
|
| length
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
});
|
|
}
|