Browse Source

test(exhook): exhook config update

JimMoen 3 years atrás
parent
commit
e2eb1da647

+ 4 - 2
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(_) ->

+ 21 - 2
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"]),
         "",