test(exhook): exhook config update

This commit is contained in:
JimMoen 2022-04-29 17:51:40 +08:00
parent ef8ed3202e
commit e2eb1da647
2 changed files with 25 additions and 4 deletions

View File

@ -178,10 +178,12 @@ t_error_update_conf(_) ->
<<"url">> => <<"http://127.0.0.1:9001">>, <<"url">> => <<"http://127.0.0.1:9001">>,
<<"enable">> => false <<"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, <<"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. ok.
t_error_server_info(_) -> t_error_server_info(_) ->

View File

@ -33,7 +33,8 @@
"exhook {\n" "exhook {\n"
" servers =\n" " servers =\n"
" [ { name = default,\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" " ]\n"
"}\n" "}\n"
@ -44,6 +45,7 @@ all() ->
t_list, t_list,
t_get, t_get,
t_add, t_add,
t_add_duplicate,
t_move_front, t_move_front,
t_move_rear, t_move_rear,
t_move_before, t_move_before,
@ -181,6 +183,23 @@ t_add(Cfg) ->
?assertMatch([<<"default">>, <<"test1">>], emqx_exhook_mgr:running()). ?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(_) -> t_move_front(_) ->
Result = request_api( Result = request_api(
post, post,
@ -263,7 +282,7 @@ t_hooks(_Cfg) ->
t_update(Cfg) -> t_update(Cfg) ->
Template = proplists:get_value(template, Cfg), Template = proplists:get_value(template, Cfg),
Instance = Template#{enable => false}, Instance = Template#{enable => false},
{ok, <<>>} = request_api( {ok, <<"{\"", _/binary>>} = request_api(
put, put,
api_path(["exhooks", "default"]), api_path(["exhooks", "default"]),
"", "",