summaryrefslogtreecommitdiffstats
path: root/tests/yanglint/non-interactive/data_present.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/yanglint/non-interactive/data_present.test')
-rw-r--r--tests/yanglint/non-interactive/data_present.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/yanglint/non-interactive/data_present.test b/tests/yanglint/non-interactive/data_present.test
new file mode 100644
index 0000000..81aac14
--- /dev/null
+++ b/tests/yanglint/non-interactive/data_present.test
@@ -0,0 +1,25 @@
+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
+
+test data_present_via_mandatory {validation of mandatory-stmt will pass only with the --present} {
+ set mods "$mdir/modleaf.yang $mdir/modmandatory.yang"
+ ly_cmd_err "$ddir/modleaf.xml $mods" "Mandatory node \"lft\" instance does not exist."
+ ly_cmd "-e $ddir/modleaf.xml $mods"
+} {}
+
+test data_present_merge {validation with --present and --merge} {
+ set mods "$mdir/modleaf.yang $mdir/modmandatory.yang $mdir/moddefault.yang"
+ set data "$ddir/modleaf.xml $ddir/moddefault.xml"
+ ly_cmd_err "-m $data $mods" "Mandatory node \"lft\" instance does not exist."
+ ly_cmd "-m -e $data $mods"
+} {}
+
+test data_present_merge_invalid {using --present and --merge but data are invalid} {
+ set mods "$mdir/modleaf.yang $mdir/modmandatory.yang"
+ set data "$ddir/modleaf.xml $ddir/modmandatory_invalid.xml"
+ ly_cmd_err "-e -m $data $mods" "Mandatory node \"lft\" instance does not exist."
+} {}
+
+cleanupTests