test: update publish api test suite
This commit is contained in:
parent
53fb8fcded
commit
5a8cab46a9
|
@ -47,8 +47,10 @@ t_publish_api(_) ->
|
||||||
Path = emqx_mgmt_api_test_util:api_path(["publish"]),
|
Path = emqx_mgmt_api_test_util:api_path(["publish"]),
|
||||||
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
Body = #{topic => ?TOPIC1, payload => Payload},
|
Body = #{topic => ?TOPIC1, payload => Payload},
|
||||||
{ok, _} = emqx_mgmt_api_test_util:request_api(post, Path, "", Auth, Body),
|
{ok, Response} = emqx_mgmt_api_test_util:request_api(post, Path, "", Auth, Body),
|
||||||
?assertEqual(receive_assert(?TOPIC1, 0, Payload), ok),
|
ResponseMap = emqx_json:decode(Response, [return_maps]),
|
||||||
|
?assertEqual([<<"id">>], maps:keys(ResponseMap)),
|
||||||
|
?assertEqual(ok, receive_assert(?TOPIC1, 0, Payload)),
|
||||||
emqtt:disconnect(Client).
|
emqtt:disconnect(Client).
|
||||||
|
|
||||||
t_publish_bulk_api(_) ->
|
t_publish_bulk_api(_) ->
|
||||||
|
@ -63,10 +65,16 @@ t_publish_bulk_api(_) ->
|
||||||
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
Body = [#{topic => ?TOPIC1, payload => Payload}, #{topic => ?TOPIC2, payload => Payload}],
|
Body = [#{topic => ?TOPIC1, payload => Payload}, #{topic => ?TOPIC2, payload => Payload}],
|
||||||
{ok, Response} = emqx_mgmt_api_test_util:request_api(post, Path, "", Auth, Body),
|
{ok, Response} = emqx_mgmt_api_test_util:request_api(post, Path, "", Auth, Body),
|
||||||
ResponseMap = emqx_json:decode(Response, [return_maps]),
|
ResponseList = emqx_json:decode(Response, [return_maps]),
|
||||||
?assertEqual(2, erlang:length(ResponseMap)),
|
?assertEqual(2, erlang:length(ResponseList)),
|
||||||
?assertEqual(receive_assert(?TOPIC1, 0, Payload), ok),
|
lists:foreach(
|
||||||
?assertEqual(receive_assert(?TOPIC2, 0, Payload), ok),
|
fun(ResponseMap) ->
|
||||||
|
?assertEqual([<<"id">>], maps:keys(ResponseMap))
|
||||||
|
end,
|
||||||
|
ResponseList
|
||||||
|
),
|
||||||
|
?assertEqual(ok, receive_assert(?TOPIC1, 0, Payload)),
|
||||||
|
?assertEqual(ok, receive_assert(?TOPIC2, 0, Payload)),
|
||||||
emqtt:disconnect(Client).
|
emqtt:disconnect(Client).
|
||||||
|
|
||||||
receive_assert(Topic, Qos, Payload) ->
|
receive_assert(Topic, Qos, Payload) ->
|
||||||
|
|
Loading…
Reference in New Issue