Merge pull request #7276 from lafirest/test/mgmt_api_subs_cover

test(mgmt): improve test coverage of emqx_mgmt_api_subscription to 96%
This commit is contained in:
JianBo He 2022-03-11 15:15:22 +08:00 committed by GitHub
commit 81ffa87354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -82,4 +82,20 @@ t_subscription_api(_) ->
SubscriptionsList2 = maps:get(<<"data">>, DataTopic2),
?assertEqual(length(SubscriptionsList2), 1),
MatchQs = uri_string:compose_query([
{"clientid", ?CLIENTID},
{"node", atom_to_list(node())},
{"qos", "0"},
{"match_topic", "t/#"}
]),
{ok, MatchRes} = emqx_mgmt_api_test_util:request_api(get, Path, MatchQs, Headers),
MatchData = emqx_json:decode(MatchRes, [return_maps]),
MatchMeta = maps:get(<<"meta">>, MatchData),
?assertEqual(1, maps:get(<<"page">>, MatchMeta)),
?assertEqual(emqx_mgmt:max_row_limit(), maps:get(<<"limit">>, MatchMeta)),
?assertEqual(2, maps:get(<<"count">>, MatchMeta)),
MatchSubs = maps:get(<<"data">>, MatchData),
?assertEqual(length(MatchSubs), 2),
emqtt:disconnect(Client).