diff options
Diffstat (limited to '')
-rw-r--r-- | tests/yanglint/non-interactive/data_xpath.test | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/yanglint/non-interactive/data_xpath.test b/tests/yanglint/non-interactive/data_xpath.test new file mode 100644 index 0000000..1d96106 --- /dev/null +++ b/tests/yanglint/non-interactive/data_xpath.test @@ -0,0 +1,42 @@ +source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}] + +set mod "$::env(YANG_MODULES_DIR)/moddatanodes.yang" +set data "$::env(TESTS_DIR)/data/moddatanodes.xml" + +test data_xpath_empty {--data-path to missing node} { + ly_cmd "-E /moddatanodes:dnc/mis $mod $data" "Empty" +} {} + +test data_xpath_leaf {--xpath to leaf node} { + ly_cmd "-E /moddatanodes:dnc/lf $mod $data" "leaf \"lf\" \\(value: \"x\"\\)" +} {} + +test data_xpath_leaflist {--xpath to leaf-list node} { + set r1 "leaf-list \"lfl\" \\(value: \"1\"\\)" + set r2 "leaf-list \"lfl\" \\(value: \"2\"\\)" + ly_cmd "-E /moddatanodes:dnc/lfl $mod $data" "$r1\n $r2" +} {} + +test data_xpath_list {--xpath to list} { + set r1 "list \"lt\" \\(\"kalf\": \"ka1\"; \"kblf\": \"kb1\";\\)" + set r2 "list \"lt\" \\(\"kalf\": \"ka2\"; \"kblf\": \"kb2\";\\)" + ly_cmd "-E /moddatanodes:dnc/con/lt $mod $data" "$r1\n $r2" +} {} + +test data_xpath_container {--xpath to container} { + ly_cmd "-E /moddatanodes:dnc/con $mod $data" "container \"con\"" +} {} + +test data_xpath_wrong_path {--xpath to a non-existent node} { + ly_cmd_err "-E /moddatanodes:dnc/wrng $mod $data" "xpath failed" +} {} + +test data_xpath_err_format {--xpath cannot be combined with --format} { + ly_cmd_err "-f xml -E /moddatanodes:dnc/lf $mod $data" "option cannot be combined" +} {} + +test data_xpath_err_default {--xpath cannot be combined with --default} { + ly_cmd_err "-d all -E /moddatanodes:dnc/lf $mod $data" "option cannot be combined" +} {} + +cleanupTests |