aboutsummaryrefslogtreecommitdiff
path: root/tests/configuration_toml.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2024-03-14 08:26:58 +0100
committerSébastien Dailly <sebastien@dailly.me>2024-03-14 08:26:58 +0100
commit6b377719c10d5ab3343fd5221f99a4a21008e25a (patch)
treea7c1e9a820d339a2f161af3e09cf9e3161286796 /tests/configuration_toml.ml
Initial commitmain
Diffstat (limited to 'tests/configuration_toml.ml')
-rw-r--r--tests/configuration_toml.ml71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/configuration_toml.ml b/tests/configuration_toml.ml
new file mode 100644
index 0000000..3c8bfc2
--- /dev/null
+++ b/tests/configuration_toml.ml
@@ -0,0 +1,71 @@
+open OUnit2
+module Expression = ImportExpression.T
+module Path = ImportDataTypes.Path
+
+let test_suit =
+ [
+ ( "parse_extern" >:: fun _ ->
+ let toml = Otoml.Parser.from_file "configuration/simple.toml" in
+ let toml = ImportConf.t_of_toml toml in
+ match toml with
+ | Error s -> raise (Failure s)
+ | Ok result ->
+ let open ImportConf.Syntax in
+ let expected =
+ {
+ target = { file = ""; tab = 1; name = "target" };
+ extern_key = Literal "_B";
+ intern_key =
+ Function
+ ( "function",
+ [
+ Path { alias = None; column = 1 };
+ Path { alias = None; column = 2 };
+ ] );
+ match_rule = None;
+ allow_missing = true;
+ }
+ in
+
+ let printer s =
+ String.concat "," (List.map ImportConf.print_extern s)
+ in
+
+ assert_equal ~printer [ expected ] result.externals );
+ ( "parse_columns" >:: fun _ ->
+ let toml = Otoml.Parser.from_file "configuration/simple.toml" in
+ let toml = ImportConf.t_of_toml toml in
+
+ match toml with
+ | Error s -> raise (Failure s)
+ | Ok result ->
+ let open Path in
+ let open Expression in
+ let expected =
+ [
+ Function
+ ( "function",
+ [
+ Path { alias = Some "target"; column = 1 };
+ Path { alias = None; column = 2 };
+ Literal "free' text";
+ ] );
+ Window
+ ( Counter,
+ [ Path { alias = Some "target"; column = 1 } ],
+ [ Path { alias = Some "target"; column = 1 } ] );
+ ]
+ in
+
+ List.iter2
+ (fun expected result ->
+ assert_equal ~printer:ImportConf.print_path_expression expected
+ result)
+ expected result.columns );
+ ( "parse_csv" >:: fun _ ->
+ let toml = Otoml.Parser.from_file "configuration/example_csv.toml" in
+ let toml = ImportConf.t_of_toml toml in
+ ignore toml );
+ ]
+
+let tests = "configuration_toml" >::: test_suit