2020-01-10 16:44:24 +01:00
|
|
|
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
|
|
use nu_test_support::playground::Playground;
|
2019-12-17 19:54:39 +01:00
|
|
|
use nu_test_support::{nu, pipeline};
|
2019-12-15 17:15:06 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn extracts_fields_from_the_given_the_pattern() {
|
2020-01-10 16:44:24 +01:00
|
|
|
Playground::setup("parse_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"key_value_separated_arepa_ingredients.txt",
|
|
|
|
r#"
|
|
|
|
VAR1=Cheese
|
|
|
|
VAR2=JonathanParsed
|
|
|
|
VAR3=NushellSecretIngredient
|
|
|
|
"#,
|
|
|
|
)]);
|
2019-12-15 17:15:06 +01:00
|
|
|
|
2020-01-10 16:44:24 +01:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), pipeline(
|
|
|
|
r#"
|
|
|
|
open key_value_separated_arepa_ingredients.txt
|
|
|
|
| parse "{Name}={Value}"
|
|
|
|
| nth 1
|
|
|
|
| get Value
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 13:03:43 +02:00
|
|
|
assert_eq!(actual.out, "JonathanParsed");
|
2020-01-10 16:44:24 +01:00
|
|
|
})
|
2019-12-15 17:15:06 +01:00
|
|
|
}
|