fix(test): improve subscriptions api suite
This commit is contained in:
parent
384d508b13
commit
dbfa7a7f0c
|
@ -24,8 +24,9 @@
|
||||||
-define(USERNAME, <<"api_username">>).
|
-define(USERNAME, <<"api_username">>).
|
||||||
|
|
||||||
%% notice: integer topic for sort response
|
%% notice: integer topic for sort response
|
||||||
-define(TOPIC1, <<"/t/0000">>).
|
-define(TOPIC1, <<"t/0000">>).
|
||||||
-define(TOPIC2, <<"/t/0001">>).
|
-define(TOPIC2, <<"$share/test_group/t/0001">>).
|
||||||
|
-define(TOPIC2_TOPIC_ONLY, <<"t/0001">>).
|
||||||
|
|
||||||
-define(TOPIC_SORT, #{?TOPIC1 => 1, ?TOPIC2 => 2}).
|
-define(TOPIC_SORT, #{?TOPIC1 => 1, ?TOPIC2 => 2}).
|
||||||
|
|
||||||
|
@ -63,16 +64,22 @@ t_subscription_api(_) ->
|
||||||
?assertEqual(maps:get(<<"clientid">>, Subscriptions1), ?CLIENTID),
|
?assertEqual(maps:get(<<"clientid">>, Subscriptions1), ?CLIENTID),
|
||||||
?assertEqual(maps:get(<<"clientid">>, Subscriptions2), ?CLIENTID),
|
?assertEqual(maps:get(<<"clientid">>, Subscriptions2), ?CLIENTID),
|
||||||
|
|
||||||
QsTopic = "topic=" ++ <<"%2Ft%2F0001">>,
|
QS = uri_string:compose_query([
|
||||||
|
{"clientid", ?CLIENTID},
|
||||||
|
{"topic", ?TOPIC2_TOPIC_ONLY},
|
||||||
|
{"node", atom_to_list(node())},
|
||||||
|
{"qos", "0"},
|
||||||
|
{"share_group", "test_group"},
|
||||||
|
{"match_topic", "t/#"}
|
||||||
|
]),
|
||||||
Headers = emqx_mgmt_api_test_util:auth_header_(),
|
Headers = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
{ok, ResponseTopic1} = emqx_mgmt_api_test_util:request_api(get, Path, QsTopic, Headers),
|
{ok, ResponseTopic2} = emqx_mgmt_api_test_util:request_api(get, Path, QS, Headers),
|
||||||
DataTopic1 = emqx_json:decode(ResponseTopic1, [return_maps]),
|
DataTopic2 = emqx_json:decode(ResponseTopic2, [return_maps]),
|
||||||
Meta1 = maps:get(<<"meta">>, DataTopic1),
|
Meta2 = maps:get(<<"meta">>, DataTopic2),
|
||||||
?assertEqual(1, maps:get(<<"page">>, Meta1)),
|
?assertEqual(1, maps:get(<<"page">>, Meta2)),
|
||||||
?assertEqual(emqx_mgmt:max_row_limit(), maps:get(<<"limit">>, Meta1)),
|
?assertEqual(emqx_mgmt:max_row_limit(), maps:get(<<"limit">>, Meta2)),
|
||||||
?assertEqual(1, maps:get(<<"count">>, Meta1)),
|
?assertEqual(1, maps:get(<<"count">>, Meta2)),
|
||||||
Subscriptions_qs1 = maps:get(<<"data">>, DataTopic1),
|
SubscriptionsList2 = maps:get(<<"data">>, DataTopic2),
|
||||||
?assertEqual(length(Subscriptions_qs1), 1),
|
?assertEqual(length(SubscriptionsList2), 1),
|
||||||
|
|
||||||
|
|
||||||
emqtt:disconnect(Client).
|
emqtt:disconnect(Client).
|
||||||
|
|
Loading…
Reference in New Issue