From e2eb1da647267c549a124e581da7e9859ae8920f Mon Sep 17 00:00:00 2001 From: JimMoen Date: Fri, 29 Apr 2022 17:51:40 +0800 Subject: [PATCH] test(exhook): exhook config update --- apps/emqx_exhook/test/emqx_exhook_SUITE.erl | 6 +++-- .../test/emqx_exhook_api_SUITE.erl | 23 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/emqx_exhook/test/emqx_exhook_SUITE.erl b/apps/emqx_exhook/test/emqx_exhook_SUITE.erl index 99bfbf3cb..74ec6c1ae 100644 --- a/apps/emqx_exhook/test/emqx_exhook_SUITE.erl +++ b/apps/emqx_exhook/test/emqx_exhook_SUITE.erl @@ -178,10 +178,12 @@ t_error_update_conf(_) -> <<"url">> => <<"http://127.0.0.1:9001">>, <<"enable">> => false }, - {ok, _} = emqx_exhook_mgr:update_config(Path, {add, DisableAnd}), + {ok, _} = emqx_exhook_mgr:update_config(Path, {update, Name, DisableAnd}), {ok, _} = emqx_exhook_mgr:update_config(Path, {delete, <<"error">>}), - {ok, _} = emqx_exhook_mgr:update_config(Path, {delete, <<"delete_not_exists">>}), + {error, not_found} = emqx_exhook_mgr:update_config( + Path, {delete, <<"delete_not_exists">>} + ), ok. t_error_server_info(_) -> diff --git a/apps/emqx_exhook/test/emqx_exhook_api_SUITE.erl b/apps/emqx_exhook/test/emqx_exhook_api_SUITE.erl index 0fe3a8ef9..c9ba65b64 100644 --- a/apps/emqx_exhook/test/emqx_exhook_api_SUITE.erl +++ b/apps/emqx_exhook/test/emqx_exhook_api_SUITE.erl @@ -33,7 +33,8 @@ "exhook {\n" " servers =\n" " [ { name = default,\n" - " url = \"http://127.0.0.1:9000\"\n" + " url = \"http://127.0.0.1:9000\",\n" + " ssl = {\"enable\": false}" " }\n" " ]\n" "}\n" @@ -44,6 +45,7 @@ all() -> t_list, t_get, t_add, + t_add_duplicate, t_move_front, t_move_rear, t_move_before, @@ -181,6 +183,23 @@ t_add(Cfg) -> ?assertMatch([<<"default">>, <<"test1">>], emqx_exhook_mgr:running()). +t_add_duplicate(Cfg) -> + Template = proplists:get_value(template, Cfg), + Instance = Template#{ + name => <<"test1">>, + url => "http://127.0.0.1:9001" + }, + + {error, _Reason} = request_api( + post, + api_path(["exhooks"]), + "", + auth_header_(), + Instance + ), + + ?assertMatch([<<"default">>, <<"test1">>], emqx_exhook_mgr:running()). + t_move_front(_) -> Result = request_api( post, @@ -263,7 +282,7 @@ t_hooks(_Cfg) -> t_update(Cfg) -> Template = proplists:get_value(template, Cfg), Instance = Template#{enable => false}, - {ok, <<>>} = request_api( + {ok, <<"{\"", _/binary>>} = request_api( put, api_path(["exhooks", "default"]), "",