Rename a function, use ?assertMatch #14079

This commit is contained in:
Michael Klishin 2025-06-16 13:18:58 +04:00
parent f13f99303a
commit a7c21a1b28
No known key found for this signature in database
GPG Key ID: 16AB14D00D613900
2 changed files with 9 additions and 10 deletions

View File

@ -52,12 +52,12 @@ delete_shovel(VHost, Name, ActingUser) ->
rabbit_log:info("Will delete runtime parameters of shovel '~ts' in virtual host '~ts'", [Name, VHost]),
ok = rabbit_runtime_parameters:clear(VHost, <<"shovel">>, Name, ActingUser);
true ->
report_connot_delete_protected_shovel(Name, VHost, ShovelParameters)
report_that_protected_shovel_cannot_be_deleted(Name, VHost, ShovelParameters)
end
end.
-spec report_connot_delete_protected_shovel(binary(), binary(), map() | [tuple()]) -> no_return().
report_connot_delete_protected_shovel(Name, VHost, ShovelParameters) ->
-spec report_that_protected_shovel_cannot_be_deleted(binary(), binary(), map() | [tuple()]) -> no_return().
report_that_protected_shovel_cannot_be_deleted(Name, VHost, ShovelParameters) ->
case rabbit_shovel_parameters:internal_owner(ShovelParameters) of
undefined ->
rabbit_misc:protocol_error(
@ -68,7 +68,7 @@ report_connot_delete_protected_shovel(Name, VHost, ShovelParameters) ->
rabbit_misc:protocol_error(
resource_locked,
"Cannot delete protected shovel '~ts' in virtual host '~ts'. It was "
"declared as an protected and can be deleted only by deleting the owner entity: ~ts",
"declared as protected, delete it with --force or delete its owner entity instead: ~ts",
[Name, VHost, rabbit_misc:rs(IOwner)])
end.

View File

@ -121,12 +121,10 @@ delete_internal_owner(Config) ->
{<<"dest-queue">>, <<"dest">>}]),
[A] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
Opts = #{node => A, vhost => <<"/">>, force => false},
{badrpc,
{'EXIT',
{amqp_error, resource_locked,
"Cannot delete protected shovel 'myshovel' in virtual host '/'. "
"It was declared as an protected and can be deleted only by deleting the owner entity: queue 'src' in vhost '/'",
none}}} = ?CMD:run([<<"myshovel">>], Opts),
?assertMatch(
{badrpc, {'EXIT', {amqp_error, resource_locked, _, none}}},
?CMD:run([<<"myshovel">>], Opts)
),
[_] = rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_shovel_status,
status, []),
@ -134,6 +132,7 @@ delete_internal_owner(Config) ->
ok = ?CMD:run([<<"myshovel">>], ForceOpts),
[] = rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_shovel_status,
status, []).
clear_param_on_different_node(Config) ->
shovel_test_utils:set_param(
Config,