Skip to content

Commit

Permalink
Add assert_configurable_module info config_parse_SUITE
Browse files Browse the repository at this point in the history
It will save a lot of time next time people would add a new module
Previous behaviour would just ignore any parameters and make an error
in deeply nested code. That would confuse people a lot.

Default behaviour is to ignore config_spec even if it is defined.
Unless module is listed in a separate module list.

Fix mod_fast_auth_token config tests.
  • Loading branch information
arcusfelis committed Jan 21, 2025
1 parent 162f141 commit 72f29f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/config/mongoose_config_spec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
process_domain_cert/1,
process_infinity_as_zero/1]).

%% For tests
-export([configurable_modules/0]).
-ignore_xref([configurable_modules/0]).

-include("mongoose_config_spec.hrl").

-type config_node() :: config_section() | config_list() | config_option().
Expand Down Expand Up @@ -753,6 +757,7 @@ configurable_modules() ->
mod_disco,
mod_event_pusher,
mod_extdisco,
mod_fast_auth_token,
mod_global_distrib,
mod_http_upload,
mod_inbox,
Expand Down
14 changes: 14 additions & 0 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3118,8 +3118,22 @@ check_iqdisc(ParentP, ParentT) when is_function(ParentT, 1) ->

check_module_defaults(Mod) ->
ExpectedCfg = default_mod_config(Mod),
case maps:size(ExpectedCfg) of
0 ->
ok;
_ ->
assert_configurable_module(mod_fast_auth_token)
end,
?cfgh([modules, Mod], ExpectedCfg, #{<<"modules">> => #{atom_to_binary(Mod) => #{}}}).

assert_configurable_module(Module) ->
case lists:member(Module, mongoose_config_spec:configurable_modules()) of
true -> ok;
false ->
ct:fail({assert_configurable_module, Module,
"Don't forget to add module into mongoose_config_spec:configurable_modules/1"})
end.

%% helpers for 'listen' tests

listener(Type, Opts) ->
Expand Down

0 comments on commit 72f29f8

Please sign in to comment.