aPiecek | 95709a4 | 2023-04-12 10:42:35 +0200 | [diff] [blame] | 1 | source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}] |
| 2 | |
| 3 | set data "$::env(TESTS_DIR)/data/moddatanodes.xml" |
| 4 | |
| 5 | test data_xpath_empty {--xpath to missing node} { |
| 6 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 7 | ly_cmd "load moddatanodes" |
| 8 | ly_cmd "data -x /moddatanodes:dnc/mis $data" "Empty" |
| 9 | }} |
| 10 | |
| 11 | test data_xpath_leaf {--xpath to leaf node} { |
| 12 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 13 | ly_cmd "load moddatanodes" |
| 14 | ly_cmd "data -x /moddatanodes:dnc/lf $data" "leaf \"lf\" \\(value: \"x\"\\)" |
| 15 | }} |
| 16 | |
| 17 | test data_xpath_leaflist {--xpath to leaf-list node} { |
| 18 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 19 | ly_cmd "load moddatanodes" |
| 20 | set r1 "leaf-list \"lfl\" \\(value: \"1\"\\)" |
| 21 | set r2 "leaf-list \"lfl\" \\(value: \"2\"\\)" |
| 22 | ly_cmd "data -x /moddatanodes:dnc/lfl $data" "$r1\r\n $r2" |
| 23 | }} |
| 24 | |
| 25 | test data_xpath_list {--xpath to list} { |
| 26 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 27 | ly_cmd "load moddatanodes" |
| 28 | set r1 "list \"lt\" \\(\"kalf\": \"ka1\"; \"kblf\": \"kb1\";\\)" |
| 29 | set r2 "list \"lt\" \\(\"kalf\": \"ka2\"; \"kblf\": \"kb2\";\\)" |
| 30 | ly_cmd "data -x /moddatanodes:dnc/con/lt $data" "$r1\r\n $r2" |
| 31 | }} |
| 32 | |
aPiecek | 1ad408a | 2023-04-12 10:45:23 +0200 | [diff] [blame] | 33 | test data_xpath_container {--xpath to container} { |
| 34 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 35 | ly_cmd "load moddatanodes" |
| 36 | ly_cmd "data -x /moddatanodes:dnc/con $data" "container \"con\"" |
| 37 | }} |
| 38 | |
aPiecek | a549c50 | 2023-04-12 11:28:31 +0200 | [diff] [blame] | 39 | test data_xpath_wrong_path {--xpath to a non-existent node} { |
| 40 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 41 | ly_cmd "load moddatanodes" |
| 42 | ly_cmd_err "data -x /moddatanodes:dnc/wrng $data" "xpath failed" |
| 43 | }} |
| 44 | |
aPiecek | 72a24c9 | 2023-04-12 15:03:05 +0200 | [diff] [blame] | 45 | test data_xpath_err_format {--xpath cannot be combined with --format} { |
| 46 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 47 | ly_cmd "load moddatanodes" |
| 48 | ly_cmd_err "data -f xml -x /moddatanodes:dnc/lf $data" "option cannot be combined" |
| 49 | }} |
| 50 | |
aPiecek | 95709a4 | 2023-04-12 10:42:35 +0200 | [diff] [blame] | 51 | test data_xpath_err_default {--xpath cannot be combined with --default} { |
| 52 | -setup $ly_setup -cleanup $ly_cleanup -body { |
| 53 | ly_cmd "load moddatanodes ietf-netconf-with-defaults" |
| 54 | ly_cmd_err "data -d all -x /moddatanodes:dnc/lf $data" "option cannot be combined" |
| 55 | }} |
| 56 | |
| 57 | cleanupTests |