From 2626d793a71ecb6b27ec722c7446cb674b1bb56f Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Mon, 9 Oct 2023 12:40:30 +0200 Subject: [PATCH] test: try to resolve schema module from PROFILE in tests --- apps/emqx_conf/src/emqx_conf.erl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/emqx_conf/src/emqx_conf.erl b/apps/emqx_conf/src/emqx_conf.erl index 1efeb4d69..f9e64ffa6 100644 --- a/apps/emqx_conf/src/emqx_conf.erl +++ b/apps/emqx_conf/src/emqx_conf.erl @@ -203,14 +203,30 @@ gen_config_md(Dir, SchemaModule, Lang) -> -spec schema_module() -> module(). schema_module() -> case os:getenv("SCHEMA_MOD") of - false -> emqx_conf_schema; - Value -> list_to_existing_atom(Value) + false -> + resolve_schema_module(); + Value -> + list_to_existing_atom(Value) end. %%-------------------------------------------------------------------- %% Internal functions %%-------------------------------------------------------------------- +-ifdef(TEST). +resolve_schema_module() -> + case os:getenv("PROFILE") of + "emqx" -> + emqx_conf_schema; + "emqx-enterprise" -> + emqx_enterprise_schema + end. +-else. +-spec resolve_schema_module() -> no_return(). +resolve_schema_module() -> + error("SCHEMA_MOD environment variable is not set"). +-endif. + %% @doc Make a resolver function that can be used to lookup the description by hocon_schema_json dump. make_desc_resolver(Lang) -> fun