mirror of
https://github.com/nushell/nushell.git
synced 2024-11-28 19:33:47 +01:00
bd0032898f
# Description - A new one is the removal of unnecessary `#` in raw strings without `"` inside. - https://rust-lang.github.io/rust-clippy/master/index.html#/needless_raw_string_hashes - The automatically applied removal of `.into_iter()` touched several places where #9648 will change to the use of the record API. If necessary I can remove them @IanManske to avoid churn with this PR. - Manually applied `.try_fold` in two places - Removed a dead `if` - Manual: Combat rightward-drift with early return
85 lines
2.5 KiB
Rust
85 lines
2.5 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::nu_with_plugins;
|
|
use nu_test_support::playground::Playground;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn infers_types() {
|
|
Playground::setup("filter_from_vcf_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"contacts.vcf",
|
|
r"
|
|
BEGIN:VCARD
|
|
VERSION:3.0
|
|
FN:John Doe
|
|
N:Doe;John;;;
|
|
EMAIL;TYPE=INTERNET:john.doe99@gmail.com
|
|
item1.ORG:'Alpine Ski Resort'
|
|
item1.X-ABLabel:Other
|
|
item2.TITLE:'Ski Instructor'
|
|
item2.X-ABLabel:Other
|
|
BDAY:19001106
|
|
NOTE:Facebook: john.doe.3\nWebsite: \nHometown: Cleveland\, Ohio
|
|
CATEGORIES:myContacts
|
|
END:VCARD
|
|
BEGIN:VCARD
|
|
VERSION:3.0
|
|
FN:Alex Smith
|
|
N:Smith;Alex;;;
|
|
TEL;TYPE=CELL:(890) 123-4567
|
|
CATEGORIES:Band,myContacts
|
|
END:VCARD
|
|
",
|
|
)]);
|
|
|
|
let cwd = dirs.test();
|
|
let actual = nu_with_plugins!(
|
|
cwd: cwd,
|
|
plugin: ("nu_plugin_formats"),
|
|
"open contacts.vcf | length"
|
|
);
|
|
|
|
assert_eq!(actual.out, "2");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn from_vcf_text_to_table() {
|
|
Playground::setup("filter_from_vcf_test_2", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"contacts.txt",
|
|
r"
|
|
BEGIN:VCARD
|
|
VERSION:3.0
|
|
FN:John Doe
|
|
N:Doe;John;;;
|
|
EMAIL;TYPE=INTERNET:john.doe99@gmail.com
|
|
item1.ORG:'Alpine Ski Resort'
|
|
item1.X-ABLabel:Other
|
|
item2.TITLE:'Ski Instructor'
|
|
item2.X-ABLabel:Other
|
|
BDAY:19001106
|
|
NOTE:Facebook: john.doe.3\nWebsite: \nHometown: Cleveland\, Ohio
|
|
CATEGORIES:myContacts
|
|
END:VCARD
|
|
",
|
|
)]);
|
|
|
|
let cwd = dirs.test();
|
|
let actual = nu_with_plugins!(
|
|
cwd: cwd,
|
|
plugin: ("nu_plugin_formats"),
|
|
r#"
|
|
open contacts.txt
|
|
| from vcf
|
|
| get properties.0
|
|
| where name == "EMAIL"
|
|
| first
|
|
| get value
|
|
"#
|
|
);
|
|
|
|
assert_eq!(actual.out, "john.doe99@gmail.com");
|
|
})
|
|
}
|