summaryrefslogtreecommitdiffstats
path: root/tests/yanglint/interactive/data_xpath.test
blob: 398cb9f70af27518726164e9d30ec95f7141a124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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_format {--xpath cannot be combined with --format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load moddatanodes"
    ly_cmd_err "data -f xml -x /moddatanodes:dnc/lf $data" "option cannot be combined"
}}

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