chore: refine case side-effect

This commit is contained in:
JianBo He 2021-11-05 15:53:20 +08:00 committed by JianBo He
parent 814e01c0cb
commit f23d2f2c92
2 changed files with 20 additions and 3 deletions

View File

@ -97,11 +97,11 @@ maps_key_take(Ks, M) ->
maps_key_take(Ks, M, []). maps_key_take(Ks, M, []).
maps_key_take([], M, Acc) -> maps_key_take([], M, Acc) ->
{lists:reverse(Acc), M}; {lists:reverse(Acc), M};
maps_key_take([K|Ks], M, Acc) -> maps_key_take([K | Ks], M, Acc) ->
case maps:take(K, M) of case maps:take(K, M) of
error -> throw(bad_key); error -> throw(bad_key);
{V, M1} -> {V, M1} ->
maps_key_take(Ks, M1, [V|Acc]) maps_key_take(Ks, M1, [V | Acc])
end. end.
-spec update_gateway(atom_or_bin(), map()) -> ok_or_err(). -spec update_gateway(atom_or_bin(), map()) -> ok_or_err().
@ -384,7 +384,7 @@ pre_config_update(UnknownReq, _RawConf) ->
-> ok | {ok, Result::any()} | {error, Reason::term()}. -> ok | {ok, Result::any()} | {error, Reason::term()}.
post_config_update(Req, NewConfig, OldConfig, _AppEnvs) when is_tuple(Req) -> post_config_update(Req, NewConfig, OldConfig, _AppEnvs) when is_tuple(Req) ->
[_Tag, GwName0|_] = tuple_to_list(Req), [_Tag, GwName0 | _] = tuple_to_list(Req),
GwName = binary_to_existing_atom(GwName0), GwName = binary_to_existing_atom(GwName0),
case {maps:get(GwName, NewConfig, undefined), case {maps:get(GwName, NewConfig, undefined),

View File

@ -26,6 +26,23 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
%% CASE-SIDE-EFFICT:
%%
%% Running-Seq:
%% emqx_authz_api_mnesia_SUITE.erl
%% emqx_gateway_api_SUITE.erl
%% emqx_machine_SUITE.erl
%%
%% Reason:
%% the `emqx_machine_boot:ensure_apps_started()` will crashed
%% on starting `emqx_authz` with dirty confs, which caused the file
%% `.._build/test/lib/emqx_conf/etc/acl.conf` could not be found
%%
%% Workaround:
%% Unload emqx_authz to avoid reboot this application
%%
application:unload(emqx_authz),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
Config. Config.