From 1edf284fed4718d0c22298ccb6c402c3a0762ce7 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 12 Mar 2024 14:32:16 -0300 Subject: [PATCH] test: trigger hocon validators when checking schema --- .../test/emqx_bridge_v2_testlib.erl | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/emqx_bridge/test/emqx_bridge_v2_testlib.erl b/apps/emqx_bridge/test/emqx_bridge_v2_testlib.erl index 6729a16e7..aa15b6eb7 100644 --- a/apps/emqx_bridge/test/emqx_bridge_v2_testlib.erl +++ b/apps/emqx_bridge/test/emqx_bridge_v2_testlib.erl @@ -132,22 +132,26 @@ parse_and_check(Kind, Type, Name, InnerConfigMap0) -> end, TypeBin = emqx_utils_conv:bin(Type), RawConf = #{RootBin => #{TypeBin => #{Name => InnerConfigMap0}}}, - #{RootBin := #{TypeBin := #{Name := InnerConfigMap}}} = hocon_tconf:check_plain( - emqx_bridge_v2_schema, - RawConf, - #{ - required => false, - atom_key => false, - make_serializable => true - } - ), - InnerConfigMap. + do_parse_and_check(RootBin, TypeBin, Name, emqx_bridge_v2_schema, RawConf). parse_and_check_connector(Type, Name, InnerConfigMap0) -> TypeBin = emqx_utils_conv:bin(Type), RawConf = #{<<"connectors">> => #{TypeBin => #{Name => InnerConfigMap0}}}, - #{<<"connectors">> := #{TypeBin := #{Name := InnerConfigMap}}} = hocon_tconf:check_plain( - emqx_connector_schema, + do_parse_and_check(<<"connectors">>, TypeBin, Name, emqx_connector_schema, RawConf). + +do_parse_and_check(RootBin, TypeBin, NameBin, SchemaMod, RawConf) -> + #{RootBin := #{TypeBin := #{NameBin := _}}} = hocon_tconf:check_plain( + SchemaMod, + RawConf, + #{ + required => false, + atom_key => false, + %% to trigger validators that otherwise aren't triggered + make_serializable => false + } + ), + #{RootBin := #{TypeBin := #{NameBin := InnerConfigMap}}} = hocon_tconf:check_plain( + SchemaMod, RawConf, #{ required => false,