fix(dashboard): meck `emqx_retainer` in SUITE

This commit is contained in:
JimMoen 2024-01-12 04:36:14 +08:00
parent 3d6b65aced
commit 7bc3a5090d
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View File

@ -145,8 +145,6 @@ dashboard_samplers_fun(Latest) ->
end
end.
monitor_current(get, #{bindings := []}) ->
emqx_utils_api:with_node_or_cluster(erlang:node(), fun emqx_dashboard_monitor:current_rate/1);
monitor_current(get, #{bindings := Bindings}) ->
RawNode = maps:get(node, Bindings, <<"all">>),
emqx_utils_api:with_node_or_cluster(RawNode, fun current_rate/1).

View File

@ -31,10 +31,13 @@ all() ->
emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) ->
meck:new(emqx_retainer, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_retainer, retained_count, fun() -> 0 end),
emqx_mgmt_api_test_util:init_suite([]),
Config.
end_per_suite(_Config) ->
meck:unload([emqx_retainer]),
emqx_mgmt_api_test_util:end_suite([]).
t_monitor_samplers_all(_Config) ->
@ -198,5 +201,5 @@ waiting_emqx_stats_and_monitor_update(WaitKey) ->
end,
meck:unload([emqx_stats]),
%% manually call monitor update
_ = emqx_dashboard_monitor:current_rate(),
_ = emqx_dashboard_monitor:current_rate_cluster(),
ok.