diff options
| author | Daniil Baturin <daniil@baturin.org> | 2016-12-15 09:56:07 +0600 |
|---|---|---|
| committer | Daniil Baturin <daniil@baturin.org> | 2016-12-15 09:56:07 +0600 |
| commit | 88cca944fa1788d4f3089c9f93c59666bfcce1fb (patch) | |
| tree | 4fb211c72964405f14b25317268ba67c5d995c61 /test/reference_tree_test.ml | |
| parent | 6f95f4191699186a14a3109f08822189d0f8331e (diff) | |
| download | vyconf-88cca944fa1788d4f3089c9f93c59666bfcce1fb.tar.gz vyconf-88cca944fa1788d4f3089c9f93c59666bfcce1fb.zip | |
T212: use a directory (normally $program_dir/validators) for external validators.
What's bad is that right now way too many things are aware of the nature of external validators,
and the validators dir (formerly validators hashtable) is passed around a lot.
We'll need to think it through.
Diffstat (limited to 'test/reference_tree_test.ml')
| -rw-r--r-- | test/reference_tree_test.ml | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/test/reference_tree_test.ml b/test/reference_tree_test.ml index 1e9a624..0616378 100644 --- a/test/reference_tree_test.ml +++ b/test/reference_tree_test.ml @@ -1,12 +1,10 @@ open OUnit2 open Reference_tree -let validators = Hashtbl.create 256 -let () = Hashtbl.add validators "anything" "true"; - Hashtbl.add validators "nothing" "false" +let get_dir test_ctxt = in_testdata_dir test_ctxt ["validators"] let raises_validation_error f = - try f (); false + try ignore @@ f (); false with Validation_error _ -> true let test_load_valid_definition test_ctxt = @@ -18,34 +16,34 @@ let test_load_valid_definition test_ctxt = let test_validate_path_leaf_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 (validate_path validators r ["system"; "host-name"; "test"]) (["system"; "host-name"], Some "test") + assert_equal (validate_path (get_dir test_ctxt) r ["system"; "host-name"; "test"]) (["system"; "host-name"], Some "test") let test_validate_path_leaf_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 (raises_validation_error (fun () -> ignore @@ validate_path validators r ["system"; "host-name"; "1234"])) true + assert_equal (raises_validation_error (fun () -> ignore @@ validate_path (get_dir test_ctxt) r ["system"; "host-name"; "1234"])) true let test_validate_path_leaf_incomplete 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 (raises_validation_error (fun () -> ignore @@ validate_path validators r ["system"; "host-name"])) true + assert_equal (raises_validation_error (fun () -> ignore @@ validate_path (get_dir test_ctxt) r ["system"; "host-name"])) true let test_validate_path_tag_node_complete_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 (validate_path validators r ["system"; "login"; "user"; "test"; "full-name"; "test user"]) + assert_equal (validate_path (get_dir test_ctxt) r ["system"; "login"; "user"; "test"; "full-name"; "test user"]) (["system"; "login"; "user"; "test"; "full-name";], Some "test user") let test_validate_path_tag_node_invalid_name 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 (raises_validation_error (fun () -> ignore @@ validate_path validators r ["system"; "login"; "user"; "999"; "full-name"; "test user"])) + assert_equal (raises_validation_error (fun () -> ignore @@ validate_path (get_dir test_ctxt) r ["system"; "login"; "user"; "999"; "full-name"; "test user"])) true let test_validate_path_tag_node_incomplete 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 (raises_validation_error (fun () -> ignore @@ validate_path validators r ["system"; "login"; "user"])) true + assert_equal (raises_validation_error (fun () -> ignore @@ validate_path (get_dir test_ctxt) r ["system"; "login"; "user"])) true let suite = |
