summaryrefslogtreecommitdiffstats
path: root/tests/yanglint/interactive/print.test
blob: 8b9d7404f13df076012a8f5de84a193747f0a1f7 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]

set ipv6_path "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address"

test print_yang {} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modleaf"
    ly_cmd "print -f yang modleaf" "leaf lfl"
}}

test print_yang_submodule {Print submodule in yang format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modinclude"
    ly_cmd "print -f yang modsub" "submodule modsub"
}}

test print_yin {} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modleaf"
    ly_cmd "print -f yin modleaf" "<leaf name=\"lfl\">"
}}

test print_yin_submodule {Print submodule in yin format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modinclude"
    ly_cmd "print -f yin modsub" "<submodule name=\"modsub\""
}}

test print_info {} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modleaf"
    ly_cmd "print -f info modleaf" "status current"
}}

test print_info_path {Print subtree in info format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load ietf-ip"
    ly_cmd "print -f info -P $ipv6_path" "^list address .* leaf prefix-length"
}}

test print_info_path_single_node {Print node in info format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load ietf-ip"
    ly_cmd "print -f info -q -P $ipv6_path" "^list address .* IPv6 addresses on the interface.\";\r\n\}$"
}}

test print_tree {} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modleaf"
    ly_cmd "print -f tree modleaf" "\\+--rw lfl"
}}

test print_tree_submodule {Print submodule in tree format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load modinclude"
    ly_cmd "print -f tree modsub" "submodule: modsub"
}}

test print_tree_path {Print subtree in tree format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load ietf-ip"
    ly_cmd "print -f tree -P $ipv6_path" "\\+--rw address.*\\+--rw prefix-length"
}}

test print_tree_path_single_node {Print node in tree format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load ietf-ip"
    ly_cmd "print -f tree -q -P $ipv6_path" "\\+--rw address\\* \\\[ip\\\]$"
}}

test print_tree_path_single_node_line_length {Print node in the tree format and limit row size} {
-setup $ly_setup -cleanup $ly_cleanup -body {
    ly_cmd "load ietf-ip"
    ly_cmd "print -f tree -L 20 -q -P $ipv6_path" "\\+--rw address\\*\r\n *\\\[ip\\\]$"
}}

cleanupTests