mirror of
https://github.com/nushell/nushell.git
synced 2024-12-18 05:02:06 +01:00
96e5fc05a3
Pick->Select rename. Integration tests changes.
97 lines
2.5 KiB
Rust
97 lines
2.5 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn adds_value_provided_if_column_is_empty() {
|
|
Playground::setup("is_empty_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"likes.csv",
|
|
r#"
|
|
first_name,last_name,rusty_at,likes
|
|
Andrés,Robalino,10/11/2013,1
|
|
Jonathan,Turner,10/12/2013,1
|
|
Jason,Gedge,10/11/2013,1
|
|
Yehuda,Katz,10/11/2013,
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open likes.csv
|
|
| empty? likes 1
|
|
| get likes
|
|
| sum
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn adds_value_provided_for_columns_that_are_empty() {
|
|
Playground::setup("is_empty_test_2", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"checks.json",
|
|
r#"
|
|
[
|
|
{"boost": 1, "check": []},
|
|
{"boost": 1, "check": ""},
|
|
{"boost": 1, "check": {}},
|
|
{"boost": null, "check": ["" {} [] ""]}
|
|
]
|
|
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open checks.json
|
|
| empty? boost check 1
|
|
| get boost check
|
|
| sum
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "8");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn value_emptiness_check() {
|
|
Playground::setup("is_empty_test_3", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"checks.json",
|
|
r#"
|
|
{
|
|
"are_empty": [
|
|
{"check": []},
|
|
{"check": ""},
|
|
{"check": {}},
|
|
{"check": ["" {} [] ""]}
|
|
]
|
|
}
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open checks.json
|
|
| get are_empty.check
|
|
| empty?
|
|
| where $it
|
|
| count
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
})
|
|
}
|