From fa11c6df9cc7c236fba99c88fa54eb3736ff2c9f Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 9 Dec 2021 16:37:19 +0800 Subject: [PATCH] test(gw): fix bad test cases --- apps/emqx_gateway/src/emqx_gateway_cli.erl | 6 +++--- apps/emqx_gateway/src/emqx_gateway_conf.erl | 4 ++-- apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/emqx_gateway/src/emqx_gateway_cli.erl b/apps/emqx_gateway/src/emqx_gateway_cli.erl index a441b384e..03d55e27e 100644 --- a/apps/emqx_gateway/src/emqx_gateway_cli.erl +++ b/apps/emqx_gateway/src/emqx_gateway_cli.erl @@ -69,7 +69,7 @@ gateway(["load", Name, Conf]) -> bin(Name), emqx_json:decode(Conf, [return_maps]) ) of - ok -> + {ok, _} -> print("ok~n"); {error, Reason} -> print("Error: ~p~n", [Reason]) @@ -88,7 +88,7 @@ gateway(["stop", Name]) -> bin(Name), #{<<"enable">> => <<"false">>} ) of - ok -> + {ok, _} -> print("ok~n"); {error, Reason} -> print("Error: ~p~n", [Reason]) @@ -99,7 +99,7 @@ gateway(["start", Name]) -> bin(Name), #{<<"enable">> => <<"true">>} ) of - ok -> + {ok, _} -> print("ok~n"); {error, Reason} -> print("Error: ~p~n", [Reason]) diff --git a/apps/emqx_gateway/src/emqx_gateway_conf.erl b/apps/emqx_gateway/src/emqx_gateway_conf.erl index da06e3a6d..351093e0f 100644 --- a/apps/emqx_gateway/src/emqx_gateway_conf.erl +++ b/apps/emqx_gateway/src/emqx_gateway_conf.erl @@ -269,9 +269,9 @@ ret_gw(GwName, {ok, #{raw_config := GwConf}}) -> NLConfs = lists:map(fun({LName, LConf}) -> do_convert_listener2(GwName, LType, LName, LConf) - end, proplists:from_map(SubConf)), + end, maps:to_list(SubConf)), [NLConfs|Acc] - end, [], proplists:from_map(LsConf)), + end, [], maps:to_list(LsConf)), {ok, maps:merge(GwConf1, #{<<"listeners">> => NLsConf})}; ret_gw(_GwName, Err) -> Err. diff --git a/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl b/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl index 18a380984..f91347a6e 100644 --- a/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl +++ b/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl @@ -86,7 +86,7 @@ t_gateway_stomp(_) -> assert_confs(GwConf, ConfResp), %% put GwConf2 = emqx_map_lib:deep_merge(GwConf, #{frame => #{max_headers => 10}}), - {200, _} = request(put, "/gateway/stomp", maps:without([name], GwConf2)), + {200, _} = request(put, "/gateway/stomp", maps:without([name, listeners], GwConf2)), {200, ConfResp2} = request(get, "/gateway/stomp"), assert_confs(GwConf2, ConfResp2), {204, _} = request(delete, "/gateway/stomp"). @@ -109,7 +109,7 @@ t_gateway_mqttsn(_) -> assert_confs(GwConf, ConfResp), %% put GwConf2 = emqx_map_lib:deep_merge(GwConf, #{predefined => []}), - {200, _} = request(put, "/gateway/mqttsn", maps:without([name], GwConf2)), + {200, _} = request(put, "/gateway/mqttsn", maps:without([name, listeners], GwConf2)), {200, ConfResp2} = request(get, "/gateway/mqttsn"), assert_confs(GwConf2, ConfResp2), {204, _} = request(delete, "/gateway/mqttsn"). @@ -130,7 +130,7 @@ t_gateway_coap(_) -> assert_confs(GwConf, ConfResp), %% put GwConf2 = emqx_map_lib:deep_merge(GwConf, #{heartbeat => <<"10s">>}), - {200, _} = request(put, "/gateway/coap", maps:without([name], GwConf2)), + {200, _} = request(put, "/gateway/coap", maps:without([name, listeners], GwConf2)), {200, ConfResp2} = request(get, "/gateway/coap"), assert_confs(GwConf2, ConfResp2), {204, _} = request(delete, "/gateway/coap"). @@ -161,7 +161,7 @@ t_gateway_lwm2m(_) -> assert_confs(GwConf, ConfResp), %% put GwConf2 = emqx_map_lib:deep_merge(GwConf, #{qmode_time_window => <<"10s">>}), - {200, _} = request(put, "/gateway/lwm2m", maps:without([name], GwConf2)), + {200, _} = request(put, "/gateway/lwm2m", maps:without([name, listeners], GwConf2)), {200, ConfResp2} = request(get, "/gateway/lwm2m"), assert_confs(GwConf2, ConfResp2), {204, _} = request(delete, "/gateway/lwm2m"). @@ -182,7 +182,7 @@ t_gateway_exproto(_) -> assert_confs(GwConf, ConfResp), %% put GwConf2 = emqx_map_lib:deep_merge(GwConf, #{server => #{bind => <<"9200">>}}), - {200, _} = request(put, "/gateway/exproto", maps:without([name], GwConf2)), + {200, _} = request(put, "/gateway/exproto", maps:without([name, listeners], GwConf2)), {200, ConfResp2} = request(get, "/gateway/exproto"), assert_confs(GwConf2, ConfResp2), {204, _} = request(delete, "/gateway/exproto").