blob: 1d961061ff3a3702b05c8b1be986f2a76fc6697e [file] [log] [blame]
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