Merge pull request #10866 from zhongwencool/add-delayed-test

test: add test for delayed update
This commit is contained in:
zhongwencool 2023-05-31 10:53:55 +08:00 committed by GitHub
commit ec580f0454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 2 deletions

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_auto_subscribe, [
{description, "Auto subscribe Application"},
{vsn, "0.1.4"},
{vsn, "0.1.5"},
{registered, []},
{mod, {emqx_auto_subscribe_app, []}},
{applications, [

View File

@ -18,6 +18,8 @@
-include_lib("emqx/include/emqx_hooks.hrl").
-behaviour(emqx_config_handler).
-define(HOOK_POINT, 'client.connected').
-define(MAX_AUTO_SUBSCRIBE, 20).

View File

@ -17,6 +17,7 @@
-module(emqx_delayed).
-behaviour(gen_server).
-behaviour(emqx_config_handler).
-include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/types.hrl").

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_modules, [
{description, "EMQX Modules"},
{vsn, "5.0.15"},
{vsn, "5.0.16"},
{modules, []},
{applications, [kernel, stdlib, emqx, emqx_ctl]},
{mod, {emqx_modules_app, []}},

View File

@ -274,3 +274,18 @@ subscribe_proc() ->
2000
end
end.
t_delayed_load_unload(_Config) ->
Conf = emqx:get_raw_config([delayed]),
Conf1 = Conf#{<<"max_delayed_messages">> => 1234},
?assertMatch({ok, _}, emqx:update_config([delayed], Conf1#{<<"enable">> := true})),
?assert(is_hooks_exist()),
?assertEqual(1234, emqx:get_config([delayed, max_delayed_messages])),
?assertMatch({ok, _}, emqx:update_config([delayed], Conf1#{<<"enable">> := false})),
?assertNot(is_hooks_exist()),
?assertMatch({ok, _}, emqx:update_config([delayed], Conf)),
ok.
is_hooks_exist() ->
Hooks = emqx_hooks:lookup('message.publish'),
false =/= lists:keyfind({emqx_delayed, on_message_publish, []}, 2, Hooks).