summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2016-12-20 20:00:58 +0700
committerDaniil Baturin <daniil@baturin.org>2016-12-20 20:00:58 +0700
commitc396043a92677bad72da56fc405651750b48dd87 (patch)
treebb6443794d3c80e8c7d3b594eed64f555f7d27d4 /test
parent5eed572bc4a383a123fc694cb328567fe0e492fb (diff)
downloadvyconf-c396043a92677bad72da56fc405651750b48dd87.tar.gz
vyconf-c396043a92677bad72da56fc405651750b48dd87.zip
Add tests for the Reference_tree.is_multi function.
Diffstat (limited to 'test')
-rw-r--r--test/data/interface_definition_sample.xml6
-rw-r--r--test/reference_tree_test.ml13
2 files changed, 19 insertions, 0 deletions
diff --git a/test/data/interface_definition_sample.xml b/test/data/interface_definition_sample.xml
index 7d4e5df..f4b950e 100644
--- a/test/data/interface_definition_sample.xml
+++ b/test/data/interface_definition_sample.xml
@@ -29,6 +29,12 @@
</constraint>
</properties>
</leafNode>
+ <leafNode name="ntp-server">
+ <properties>
+ <help>NTP server address</help>
+ <multi/>
+ </properties>
+ </leafNode>
<node name="options">
<children>
<leafNode name="reboot-on-panic">
diff --git a/test/reference_tree_test.ml b/test/reference_tree_test.ml
index aea654d..8ffc079 100644
--- a/test/reference_tree_test.ml
+++ b/test/reference_tree_test.ml
@@ -61,6 +61,17 @@ let test_validate_path_valueless_node_valid test_ctxt =
assert_equal (validate_path (get_dir test_ctxt) r ["system"; "options"; "reboot-on-panic"])
(["system"; "options"; "reboot-on-panic"], None)
+let test_is_multi_valid test_ctxt =
+ let r = Vytree.make default_data "root" in
+ let r = load_from_xml r (in_testdata_dir test_ctxt ["interface_definition_sample.xml"]) in
+ assert_equal (is_multi r ["system"; "ntp-server"]) true
+
+let test_is_multi_invalid test_ctxt =
+ let r = Vytree.make default_data "root" in
+ let r = load_from_xml r (in_testdata_dir test_ctxt ["interface_definition_sample.xml"]) in
+ assert_equal (is_multi r ["system"; "host-name"]) false
+
+
let suite =
"Util tests" >::: [
"test_load_valid_definition" >:: test_load_valid_definition;
@@ -73,6 +84,8 @@ let suite =
"test_validate_path_garbage_after_value" >:: test_validate_path_garbage_after_value;
"test_validate_path_valueless_node_with_value" >:: test_validate_path_valueless_node_with_value;
"test_validate_path_valueless_node_valid" >:: test_validate_path_valueless_node_valid;
+ "test_is_multi_valid" >:: test_is_multi_valid;
+ "test_is_multi_invalid" >:: test_is_multi_invalid;
]
let () =