fix(jwt_sup): delete the worker spec from the supervision tree

This commit is contained in:
Thales Macedo Garitezi 2022-12-29 10:25:35 -03:00
parent 823efbaed3
commit ea209585b5
2 changed files with 6 additions and 2 deletions

View File

@ -62,8 +62,10 @@ ensure_worker_present(Id, Config) ->
-spec ensure_worker_deleted(worker_id()) -> ok.
ensure_worker_deleted(Id) ->
case supervisor:terminate_child(?MODULE, Id) of
ok -> ok;
{error, not_found} -> ok
ok ->
ok = supervisor:delete_child(?MODULE, Id);
{error, not_found} ->
ok
end.
jwt_worker_child_spec(Id, Config) ->

View File

@ -259,4 +259,6 @@ t_start_supervised_worker(_Config) ->
%% ensure it cleans up its own tokens to avoid leakage when
%% probing/testing rule resources.
?assertEqual({error, not_found}, emqx_rule_engine_jwt:lookup_jwt(TId, ResourceId)),
%% ensure the specs are removed from the supervision tree.
?assertEqual([], supervisor:which_children(emqx_rule_engine_jwt_sup)),
ok.