blob: 398cb9f70af27518726164e9d30ec95f7141a124 [file] [log] [blame]
aPiecek95709a42023-04-12 10:42:35 +02001source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
2
3set data "$::env(TESTS_DIR)/data/moddatanodes.xml"
4
5test 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
11test 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
17test 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
25test 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
aPiecek1ad408a2023-04-12 10:45:23 +020033test 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
aPieceka549c502023-04-12 11:28:31 +020039test 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
aPiecek72a24c92023-04-12 15:03:05 +020045test 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
aPiecek95709a42023-04-12 10:42:35 +020051test 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
57cleanupTests