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