test: rename return_body to return_all in emqx_mgmt api test util
This commit is contained in:
parent
d22756d99e
commit
0242d5f360
|
@ -354,7 +354,7 @@ call_deprecated_send_api(ClientId, Cmd, Query) ->
|
||||||
call_send_api(ClientId, Cmd, Query, API) ->
|
call_send_api(ClientId, Cmd, Query, API) ->
|
||||||
ApiPath = emqx_mgmt_api_test_util:api_path([API, ClientId, Cmd]),
|
ApiPath = emqx_mgmt_api_test_util:api_path([API, ClientId, Cmd]),
|
||||||
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
Opts = #{return_body => true},
|
Opts = #{return_all => true},
|
||||||
{ok, {{"HTTP/1.1", StatusCode, _}, _Headers, Response}} = emqx_mgmt_api_test_util:request_api(
|
{ok, {{"HTTP/1.1", StatusCode, _}, _Headers, Response}} = emqx_mgmt_api_test_util:request_api(
|
||||||
post, ApiPath, Query, Auth, [], Opts
|
post, ApiPath, Query, Auth, [], Opts
|
||||||
),
|
),
|
||||||
|
|
|
@ -228,10 +228,10 @@ t_configs_node({'end', _}) ->
|
||||||
t_configs_node(_) ->
|
t_configs_node(_) ->
|
||||||
Node = atom_to_list(node()),
|
Node = atom_to_list(node()),
|
||||||
|
|
||||||
?assertEqual({ok, <<"self">>}, get_configs(Node, #{return_body => true})),
|
?assertEqual({ok, <<"self">>}, get_configs(Node, #{return_all => true})),
|
||||||
?assertEqual({ok, <<"other">>}, get_configs("other_node", #{return_body => true})),
|
?assertEqual({ok, <<"other">>}, get_configs("other_node", #{return_all => true})),
|
||||||
|
|
||||||
{ExpType, ExpRes} = get_configs("unknown_node", #{return_body => true}),
|
{ExpType, ExpRes} = get_configs("unknown_node", #{return_all => true}),
|
||||||
?assertEqual(error, ExpType),
|
?assertEqual(error, ExpType),
|
||||||
?assertMatch({{_, 404, _}, _, _}, ExpRes),
|
?assertMatch({{_, 404, _}, _, _}, ExpRes),
|
||||||
{_, _, Body} = ExpRes,
|
{_, _, Body} = ExpRes,
|
||||||
|
|
|
@ -163,7 +163,7 @@ t_publish_too_large(Config) ->
|
||||||
"",
|
"",
|
||||||
Auth,
|
Auth,
|
||||||
Body,
|
Body,
|
||||||
#{return_body => true}
|
#{return_all => true}
|
||||||
),
|
),
|
||||||
?assertMatch({_, 400, _}, Summary),
|
?assertMatch({_, 400, _}, Summary),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
|
@ -286,7 +286,7 @@ t_publish_bulk_dispatch_one_message_invalid_topic(Config) when is_list(Config) -
|
||||||
"",
|
"",
|
||||||
Auth,
|
Auth,
|
||||||
Body,
|
Body,
|
||||||
#{return_body => true}
|
#{return_all => true}
|
||||||
),
|
),
|
||||||
?assertMatch({_, 400, _}, Summary),
|
?assertMatch({_, 400, _}, Summary),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
|
@ -325,7 +325,7 @@ t_publish_bulk_dispatch_failure(Config) when is_list(Config) ->
|
||||||
"",
|
"",
|
||||||
Auth,
|
Auth,
|
||||||
Body,
|
Body,
|
||||||
#{return_body => true}
|
#{return_all => true}
|
||||||
),
|
),
|
||||||
?assertMatch({_, 503, _}, Summary),
|
?assertMatch({_, 503, _}, Summary),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
|
|
|
@ -89,20 +89,20 @@ request_api(Method, Url, QueryParams, AuthOrHeaders, Body, Opts) when
|
||||||
).
|
).
|
||||||
|
|
||||||
do_request_api(Method, Request, Opts) ->
|
do_request_api(Method, Request, Opts) ->
|
||||||
ReturnBody = maps:get(return_body, Opts, false),
|
ReturnAll = maps:get(return_all, Opts, false),
|
||||||
ct:pal("Method: ~p, Request: ~p", [Method, Request]),
|
ct:pal("Method: ~p, Request: ~p", [Method, Request]),
|
||||||
case httpc:request(Method, Request, [], []) of
|
case httpc:request(Method, Request, [], []) of
|
||||||
{error, socket_closed_remotely} ->
|
{error, socket_closed_remotely} ->
|
||||||
{error, socket_closed_remotely};
|
{error, socket_closed_remotely};
|
||||||
{ok, {{"HTTP/1.1", Code, _} = Reason, Headers, Body}} when
|
{ok, {{"HTTP/1.1", Code, _} = Reason, Headers, Body}} when
|
||||||
Code >= 200 andalso Code =< 299 andalso ReturnBody
|
Code >= 200 andalso Code =< 299 andalso ReturnAll
|
||||||
->
|
->
|
||||||
{ok, {Reason, Headers, Body}};
|
{ok, {Reason, Headers, Body}};
|
||||||
{ok, {{"HTTP/1.1", Code, _}, _, Body}} when
|
{ok, {{"HTTP/1.1", Code, _}, _, Body}} when
|
||||||
Code >= 200 andalso Code =< 299
|
Code >= 200 andalso Code =< 299
|
||||||
->
|
->
|
||||||
{ok, Body};
|
{ok, Body};
|
||||||
{ok, {Reason, Headers, Body}} when ReturnBody ->
|
{ok, {Reason, Headers, Body}} when ReturnAll ->
|
||||||
{error, {Reason, Headers, Body}};
|
{error, {Reason, Headers, Body}};
|
||||||
{ok, {Reason, _Headers, _Body}} ->
|
{ok, {Reason, _Headers, _Body}} ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
|
|
Loading…
Reference in New Issue