refactor: delete emqx_resource:remove api

this api is only used in tests,
changed to call the _local flavor instead
This commit is contained in:
Zaiming (Stone) Shi 2024-02-20 19:50:33 +01:00
parent 8541d2efc1
commit 06e0a7f2ed
2 changed files with 4 additions and 9 deletions

View File

@ -47,7 +47,6 @@
recreate_local/3, recreate_local/3,
recreate_local/4, recreate_local/4,
%% remove the config and stop the instance %% remove the config and stop the instance
remove/1,
remove_local/1, remove_local/1,
reset_metrics/1, reset_metrics/1,
reset_metrics_local/1, reset_metrics_local/1,
@ -307,10 +306,6 @@ recreate_local(ResId, ResourceType, Config) ->
recreate_local(ResId, ResourceType, Config, Opts) -> recreate_local(ResId, ResourceType, Config, Opts) ->
emqx_resource_manager:recreate(ResId, ResourceType, Config, Opts). emqx_resource_manager:recreate(ResId, ResourceType, Config, Opts).
-spec remove(resource_id()) -> ok | {error, Reason :: term()}.
remove(ResId) ->
emqx_resource_proto_v1:remove(ResId).
-spec remove_local(resource_id()) -> ok. -spec remove_local(resource_id()) -> ok.
remove_local(ResId) -> remove_local(ResId) ->
case emqx_resource_manager:remove(ResId) of case emqx_resource_manager:remove(ResId) of

View File

@ -46,7 +46,7 @@ init_per_testcase(_, Config) ->
end_per_testcase(_, _Config) -> end_per_testcase(_, _Config) ->
snabbkaffe:stop(), snabbkaffe:stop(),
_ = emqx_resource:remove(?ID), _ = emqx_resource:remove_local(?ID),
emqx_common_test_helpers:call_janitor(), emqx_common_test_helpers:call_janitor(),
ok. ok.
@ -110,8 +110,8 @@ t_create_remove(_) ->
?assert(is_process_alive(Pid)), ?assert(is_process_alive(Pid)),
?assertEqual(ok, emqx_resource:remove(?ID)), ?assertEqual(ok, emqx_resource:remove_local(?ID)),
?assertMatch(ok, emqx_resource:remove(?ID)), ?assertMatch(ok, emqx_resource:remove_local(?ID)),
?assertNot(is_process_alive(Pid)) ?assertNot(is_process_alive(Pid))
end, end,
@ -1218,7 +1218,7 @@ t_reset_metrics(_) ->
{ok, #{pid := Pid}} = emqx_resource:query(?ID, get_state), {ok, #{pid := Pid}} = emqx_resource:query(?ID, get_state),
emqx_resource:reset_metrics(?ID), emqx_resource:reset_metrics(?ID),
?assert(is_process_alive(Pid)), ?assert(is_process_alive(Pid)),
ok = emqx_resource:remove(?ID), ok = emqx_resource:remove_local(?ID),
?assertNot(is_process_alive(Pid)). ?assertNot(is_process_alive(Pid)).
t_auto_retry(_) -> t_auto_retry(_) ->