Skip to content

Commit

Permalink
test: try to resolve schema module from PROFILE in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zmstone committed Oct 10, 2023
1 parent 2b44349 commit 2626d79
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apps/emqx_conf/src/emqx_conf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2626d79

Please sign in to comment.