From 490894620b18618ed2dd1bbd77391a0b35c36dfb Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 28 Apr 2025 14:51:11 +0800 Subject: [PATCH] add tests --- apps/iot/src/iot_ai_router.erl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/iot/src/iot_ai_router.erl b/apps/iot/src/iot_ai_router.erl index c52bb39..ecd43c9 100644 --- a/apps/iot/src/iot_ai_router.erl +++ b/apps/iot/src/iot_ai_router.erl @@ -12,6 +12,7 @@ %% API -export([route_uuid/3]). +-export([set_tests/1]). -spec route_uuid(RouterUUID :: binary(), EventType :: integer(), Params :: map()) -> no_return(). route_uuid(RouterUUID, EventType, Params) when is_binary(RouterUUID), is_integer(EventType), is_map(Params) -> @@ -21,10 +22,19 @@ route_uuid(RouterUUID, EventType, Params) when is_binary(RouterUUID), is_integer lager:debug("[iot_ai_router] hget uuid: ~p, location_code: ~p", [RouterUUID, LocationCode]), %% 动火离人推送给金智 2024-12-02, 2边都要推送 lists:member(EventType, [15]) andalso iot_donghuoliren_endpoint:forward(LocationCode, DynamicLocationCode, EventType, Params), - %% 动火离人推送给金智 2024-03-21 - iot_jinzhi_endpoint:forward(LocationCode, DynamicLocationCode, EventType, Params); + + TestEventTypes = application:get_env(iot, test_event_types, []), + case lists:member(EventType, TestEventTypes) of + true -> + lager:debug("[iot_ai_router] event_type: ~p, is test", [EventType]); + false -> + iot_jinzhi_endpoint:forward(LocationCode, DynamicLocationCode, EventType, Params); + end; {ok, _} -> lager:debug("[iot_ai_router] hget location_code, uuid: ~p, not found", [RouterUUID]); {error, Reason} -> lager:debug("[iot_ai_router] hget location_code uuid: ~p, get error: ~p", [RouterUUID, Reason]) - end. \ No newline at end of file + end. + +set_tests(TestEventTypes) when is_list(TestEventTypes) -> + application:set_env(iot, test_event_types, TestEventTypes).