Skip to content

Commit 11cdf95

Browse files
michaelklishinmergify[bot]
authored andcommitted
Test improvements #16225
(cherry picked from commit d0d0b70) (cherry picked from commit 820d570)
1 parent 77ad2aa commit 11cdf95

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

deps/rabbitmq_exchange_federation/test/unit_SUITE.erl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,16 @@ start_child_handles_already_present(_Config) ->
8484
XName = #resource{virtual_host = <<"/">>, kind = exchange, name = <<"x">>},
8585
X = #exchange{name = XName, type = direct, durable = true,
8686
auto_delete = false, internal = false, arguments = []},
87-
Self = self(),
87+
ExpectedId = (rabbit_exchange:immutable(X))#exchange{policy = X#exchange.policy},
8888
ok = meck:new(mirrored_supervisor, [unstick, passthrough]),
8989
ok = meck:expect(mirrored_supervisor, start_child,
9090
fun(_Sup, _ChildSpec) -> {error, already_present} end),
9191
ok = meck:expect(mirrored_supervisor, delete_child,
92-
fun(_Sup, _Id) -> Self ! delete_child_called, ok end),
92+
fun(_Sup, _Id) -> ok end),
9393
try
9494
?assertEqual(ok, rabbit_federation_exchange_link_sup_sup:start_child(X)),
95-
receive
96-
delete_child_called -> ok
97-
after 1000 ->
98-
ct:fail("delete_child/2 was not called to clean up stale spec")
99-
end
95+
?assert(meck:called(mirrored_supervisor, delete_child,
96+
[rabbit_federation_exchange_link_sup_sup, ExpectedId]))
10097
after
10198
ok = meck:unload(mirrored_supervisor)
10299
end.

deps/rabbitmq_queue_federation/test/unit_SUITE.erl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,16 @@ adjust_clear_upstream_when_supervisor_not_running(_Config) ->
8383
start_child_handles_already_present(_Config) ->
8484
Name = #resource{virtual_host = <<"/">>, kind = queue, name = <<"q">>},
8585
Q = amqqueue:new(Name, none, true, false, none, [], <<"/">>, #{}),
86-
Self = self(),
86+
ExpectedId = amqqueue:set_policy(amqqueue:set_immutable(Q), amqqueue:get_policy(Q)),
8787
ok = meck:new(mirrored_supervisor, [unstick, passthrough]),
8888
ok = meck:expect(mirrored_supervisor, start_child,
8989
fun(_Sup, _ChildSpec) -> {error, already_present} end),
9090
ok = meck:expect(mirrored_supervisor, delete_child,
91-
fun(_Sup, _Id) -> Self ! delete_child_called, ok end),
91+
fun(_Sup, _Id) -> ok end),
9292
try
9393
?assertEqual(ok, rabbit_federation_queue_link_sup_sup:start_child(Q)),
94-
receive
95-
delete_child_called -> ok
96-
after 1000 ->
97-
ct:fail("delete_child/2 was not called to clean up stale spec")
98-
end
94+
?assert(meck:called(mirrored_supervisor, delete_child,
95+
[rabbit_federation_queue_link_sup_sup, ExpectedId]))
9996
after
10097
ok = meck:unload(mirrored_supervisor)
10198
end.

0 commit comments

Comments
 (0)