mirror of
https://github.com/nushell/nushell.git
synced 2024-12-26 00:50:03 +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.
69 lines
1.5 KiB
Rust
69 lines
1.5 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn rows() {
|
|
Playground::setup("take_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"caballeros.csv",
|
|
r#"
|
|
name,lucky_code
|
|
Andrés,1
|
|
JT,1
|
|
Jason,2
|
|
Yehuda,1
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open caballeros.csv
|
|
| take 3
|
|
| get lucky_code
|
|
| math sum
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn rows_with_no_arguments_should_lead_to_error() {
|
|
Playground::setup("take_test_2", |dirs, _sandbox| {
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"[1 2 3] | take"#
|
|
));
|
|
|
|
assert!(actual.err.contains("missing_positional"));
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn fails_on_string() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
"foo bar" | take 2
|
|
"#
|
|
));
|
|
|
|
assert!(actual.err.contains("only_supports_this_input_type"));
|
|
}
|
|
|
|
#[test]
|
|
// covers a situation where `take` used to behave strangely on list<binary> input
|
|
fn works_with_binary_list() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
([0x[01 11]] | take 1 | get 0) == 0x[01 11]
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "true");
|
|
}
|