aPiecek | 613f237 | 2023-04-12 14:39:09 +0200 | [diff] [blame] | 1 | source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}] |
| 2 | |
| 3 | set mod "$::env(YANG_MODULES_DIR)/moddatanodes.yang" |
| 4 | set data "$::env(TESTS_DIR)/data/moddatanodes.xml" |
| 5 | |
| 6 | test data_xpath_empty {--data-path to missing node} { |
| 7 | ly_cmd "-E /moddatanodes:dnc/mis $mod $data" "Empty" |
| 8 | } {} |
| 9 | |
| 10 | test data_xpath_leaf {--xpath to leaf node} { |
| 11 | ly_cmd "-E /moddatanodes:dnc/lf $mod $data" "leaf \"lf\" \\(value: \"x\"\\)" |
| 12 | } {} |
| 13 | |
| 14 | test data_xpath_leaflist {--xpath to leaf-list node} { |
| 15 | set r1 "leaf-list \"lfl\" \\(value: \"1\"\\)" |
| 16 | set r2 "leaf-list \"lfl\" \\(value: \"2\"\\)" |
| 17 | ly_cmd "-E /moddatanodes:dnc/lfl $mod $data" "$r1\n $r2" |
| 18 | } {} |
| 19 | |
| 20 | test data_xpath_list {--xpath to list} { |
| 21 | set r1 "list \"lt\" \\(\"kalf\": \"ka1\"; \"kblf\": \"kb1\";\\)" |
| 22 | set r2 "list \"lt\" \\(\"kalf\": \"ka2\"; \"kblf\": \"kb2\";\\)" |
| 23 | ly_cmd "-E /moddatanodes:dnc/con/lt $mod $data" "$r1\n $r2" |
| 24 | } {} |
| 25 | |
| 26 | test data_xpath_container {--xpath to container} { |
| 27 | ly_cmd "-E /moddatanodes:dnc/con $mod $data" "container \"con\"" |
| 28 | } {} |
| 29 | |
| 30 | test data_xpath_wrong_path {--xpath to a non-existent node} { |
| 31 | ly_cmd_err "-E /moddatanodes:dnc/wrng $mod $data" "xpath failed" |
| 32 | } {} |
| 33 | |
| 34 | test data_xpath_err_format {--xpath cannot be combined with --format} { |
| 35 | ly_cmd_err "-f xml -E /moddatanodes:dnc/lf $mod $data" "option cannot be combined" |
| 36 | } {} |
| 37 | |
| 38 | test data_xpath_err_default {--xpath cannot be combined with --default} { |
| 39 | ly_cmd_err "-d all -E /moddatanodes:dnc/lf $mod $data" "option cannot be combined" |
| 40 | } {} |
| 41 | |
| 42 | cleanupTests |