Extract out xpath to a plugin. (#2661)

This commit is contained in:
Andrés N. Robalino
2020-10-12 18:18:39 -05:00
committed by GitHub
parent 2573441e28
commit 4e931fa73f
14 changed files with 292 additions and 203 deletions

View File

@ -1,41 +0,0 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn position_function_in_predicate() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo "<?xml version="1.0" encoding="UTF-8"?><a><b/><b/></a>" | from xml | to xml | xpath "count(//a/*[position() = 2])"
"#
));
assert_eq!(actual.out, "1.0000");
}
#[test]
fn functions_implicitly_coerce_argument_types() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo "<?xml version="1.0" encoding="UTF-8"?><a>true</a>" | from xml | to xml | xpath "count(//*[contains(., true)])"
"#
));
assert_eq!(actual.out, "1.0000");
}
#[test]
fn find_guid_permilink_is_true() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open jonathan.xml
| to xml
| xpath '//guid/@isPermaLink'
"#
));
assert_eq!(actual.out, "true");
}