summaryrefslogtreecommitdiffstats
path: root/tests/yanglint/non-interactive/format.test
blob: 8df5544c12c434bad25f8e23e5cf17a8313f5996 (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
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}]

set mdir $::env(YANG_MODULES_DIR)
set ddir $::env(TESTS_DIR)/data
set ipv6_path "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address"

test format_yang {} {
    ly_cmd "-f yang $mdir/modleaf.yang" "leaf lfl"
} {}

test format_yang_submodule {Print submodule in yang format} {
    ly_cmd "-s modsub -f yang $mdir/modinclude.yang" "submodule modsub"
} {}

test format_yin {} {
    ly_cmd "-f yin $mdir/modleaf.yang" "<leaf name=\"lfl\">"
} {}

test format_yin_submodule {Print submodule in yin format} {
    ly_cmd "-s modsub -f yin $mdir/modinclude.yang" "<submodule name=\"modsub\""
} {}

test format_info {} {
    ly_cmd "-f info $mdir/modleaf.yang" "status current"
} {}

test format_tree {} {
    ly_cmd "-f tree $mdir/modleaf.yang" "\\+--rw lfl"
} {}

test format_data_xml {Print data in xml format} {
    ly_cmd "-f xml $mdir/modleaf.yang $ddir/modleaf.xml" "<lfl xmlns=\"urn:yanglint:modleaf\">7</lfl>"
} {}

test format_data_json {Print data in json format} {
    ly_cmd "-f json $mdir/modleaf.yang $ddir/modleaf.xml" "{\n  \"modleaf:lfl\": 7\n}"
} {}

test format_data_lyb_err {Printing in LYB format: expect error due to missing parameter} {
    ly_cmd_err "-f lyb $mdir/modleaf.yang $ddir/modleaf.xml" "The LYB format requires the -o"
} {}

test format_tree_submodule {Print submodule in tree format} {
    ly_cmd "-s modsub -f tree $mdir/modinclude.yang" "submodule: modsub"
} {}

test format_tree_path {Print subtree in tree format} {
    ly_cmd "-f tree -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address.*\\+--rw prefix-length"
} {}

test format_tree_path_single_node {Print node in tree format} {
    ly_cmd "-f tree -q -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address\\* \\\[ip\\\]$"
} {}

test format_tree_path_single_node_line_length {Print node in the tree format and limit row size} {
    ly_cmd "-f tree -L 20 -q -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address\\*\n *\\\[ip\\\]$"
} {}

test format_feature_param_one_module {Show features for one module} {
    ly_cmd "-f feature-param $mdir/ietf-ip.yang" " -F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf" -ex
} {}

test format_feature_param_more_modules {Show a mix of modules with and without features} {

    set features " -F modfeature:ftr1,ftr2\
-F modleaf:\
-F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf"

    ly_cmd "-f feature-param $mdir/modfeature.yang $mdir/modleaf.yang $mdir/ietf-ip.yang" $features -ex
} {}

cleanupTests