blob: 1d961061ff3a3702b05c8b1be986f2a76fc6697e [file] [log] [blame]
aPiecek613f2372023-04-12 14:39:09 +02001source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}]
2
3set mod "$::env(YANG_MODULES_DIR)/moddatanodes.yang"
4set data "$::env(TESTS_DIR)/data/moddatanodes.xml"
5
6test data_xpath_empty {--data-path to missing node} {
7 ly_cmd "-E /moddatanodes:dnc/mis $mod $data" "Empty"
8} {}
9
10test data_xpath_leaf {--xpath to leaf node} {
11 ly_cmd "-E /moddatanodes:dnc/lf $mod $data" "leaf \"lf\" \\(value: \"x\"\\)"
12} {}
13
14test 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
20test 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
26test data_xpath_container {--xpath to container} {
27 ly_cmd "-E /moddatanodes:dnc/con $mod $data" "container \"con\""
28} {}
29
30test data_xpath_wrong_path {--xpath to a non-existent node} {
31 ly_cmd_err "-E /moddatanodes:dnc/wrng $mod $data" "xpath failed"
32} {}
33
34test 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
38test 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
42cleanupTests