blob: 25da7748e27f9d77c78df6a7a92eabfd88d3e887 [file] [log] [blame]
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
set data "$::env(TESTS_DIR)/data/moddatanodes.xml"
test data_xpath_empty {--xpath to missing node} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes"
ly_cmd "data -x /moddatanodes:dnc/mis $data" "Empty"
}}
test data_xpath_leaf {--xpath to leaf node} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes"
ly_cmd "data -x /moddatanodes:dnc/lf $data" "leaf \"lf\" \\(value: \"x\"\\)"
}}
test data_xpath_leaflist {--xpath to leaf-list node} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes"
set r1 "leaf-list \"lfl\" \\(value: \"1\"\\)"
set r2 "leaf-list \"lfl\" \\(value: \"2\"\\)"
ly_cmd "data -x /moddatanodes:dnc/lfl $data" "$r1\r\n $r2"
}}
test data_xpath_list {--xpath to list} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes"
set r1 "list \"lt\" \\(\"kalf\": \"ka1\"; \"kblf\": \"kb1\";\\)"
set r2 "list \"lt\" \\(\"kalf\": \"ka2\"; \"kblf\": \"kb2\";\\)"
ly_cmd "data -x /moddatanodes:dnc/con/lt $data" "$r1\r\n $r2"
}}
test data_xpath_container {--xpath to container} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes"
ly_cmd "data -x /moddatanodes:dnc/con $data" "container \"con\""
}}
test data_xpath_wrong_path {--xpath to a non-existent node} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes"
ly_cmd_err "data -x /moddatanodes:dnc/wrng $data" "xpath failed"
}}
test data_xpath_err_default {--xpath cannot be combined with --default} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load moddatanodes ietf-netconf-with-defaults"
ly_cmd_err "data -d all -x /moddatanodes:dnc/lf $data" "option cannot be combined"
}}
cleanupTests