Просмотр исходного кода

fix(rules): update test cases for emqx_rule_engine_SUITE

Shawn 4 лет назад
Родитель
Сommit
f33e28af6d

+ 7 - 4
apps/emqx_rule_engine/src/emqx_rule_funcs.erl

@@ -333,8 +333,10 @@ republish(Topic, Payload, Qos, Retain) ->
 '+'(X, Y) when is_number(X), is_number(Y) ->
     X + Y;
 
-%% concat 2 strings
-'+'(X, Y) when is_binary(X), is_binary(Y) ->
+%% string concatenation
+%% this requires one of the arguments is string, the other argument will be converted
+%% to string automatically (implicit conversion)
+'+'(X, Y) when is_binary(X); is_binary(Y) ->
     concat(X, Y).
 
 '-'(X, Y) when is_number(X), is_number(Y) ->
@@ -635,8 +637,9 @@ tokens(S, Separators) ->
 tokens(S, Separators, <<"nocrlf">>) ->
     [list_to_binary(R) || R <- string:lexemes(binary_to_list(S), binary_to_list(Separators) ++ [$\r,$\n,[$\r,$\n]])].
 
-concat(S1, S2) when is_binary(S1), is_binary(S2) ->
-    unicode:characters_to_binary([S1, S2], unicode).
+%% implicit convert args to strings, and then do concatenation
+concat(S1, S2) ->
+    unicode:characters_to_binary([str(S1), str(S2)], unicode).
 
 sprintf_s(Format, Args) when is_list(Args) ->
     erlang:iolist_to_binary(io_lib:format(binary_to_list(Format), Args)).

Разница между файлами не показана из-за своего большого размера
+ 363 - 1273
apps/emqx_rule_engine/test/emqx_rule_engine_SUITE.erl


+ 0 - 148
apps/emqx_rule_engine/test/emqx_rule_registry_SUITE.erl

@@ -1,148 +0,0 @@
-%%--------------------------------------------------------------------
-%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
-%%
-%% Licensed under the Apache License, Version 2.0 (the "License");
-%% you may not use this file except in compliance with the License.
-%% You may obtain a copy of the License at
-%%
-%%     http://www.apache.org/licenses/LICENSE-2.0
-%%
-%% Unless required by applicable law or agreed to in writing, software
-%% distributed under the License is distributed on an "AS IS" BASIS,
-%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%% See the License for the specific language governing permissions and
-%% limitations under the License.
-%%--------------------------------------------------------------------
-
--module(emqx_rule_registry_SUITE).
-
--compile(export_all).
--compile(nowarn_export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
-all() -> emqx_ct:all(?MODULE).
-
-init_per_testcase(_TestCase, Config) ->
-    Config.
-
-end_per_testcase(_TestCase, Config) ->
-    Config.
-
-% t_mnesia(_) ->
-%     error('TODO').
-
-% t_dump(_) ->
-%     error('TODO').
-
-% t_start_link(_) ->
-%     error('TODO').
-
-% t_get_rules_for_topic(_) ->
-%     error('TODO').
-
-% t_add_rules(_) ->
-%     error('TODO').
-
-% t_remove_rules(_) ->
-%     error('TODO').
-
-% t_add_action(_) ->
-%     error('TODO').
-
-% t_remove_action(_) ->
-%     error('TODO').
-
-% t_remove_actions(_) ->
-%     error('TODO').
-
-% t_init(_) ->
-%     error('TODO').
-
-% t_handle_call(_) ->
-%     error('TODO').
-
-% t_handle_cast(_) ->
-%     error('TODO').
-
-% t_handle_info(_) ->
-%     error('TODO').
-
-% t_terminate(_) ->
-%     error('TODO').
-
-% t_code_change(_) ->
-%     error('TODO').
-
-% t_get_resource_types(_) ->
-%     error('TODO').
-
-% t_get_resources_by_type(_) ->
-%     error('TODO').
-
-% t_get_actions_for(_) ->
-%     error('TODO').
-
-% t_get_actions(_) ->
-%     error('TODO').
-
-% t_get_action_instance_params(_) ->
-%     error('TODO').
-
-% t_remove_action_instance_params(_) ->
-%     error('TODO').
-
-% t_remove_resource_params(_) ->
-%     error('TODO').
-
-% t_add_action_instance_params(_) ->
-%     error('TODO').
-
-% t_add_resource_params(_) ->
-%     error('TODO').
-
-% t_find_action(_) ->
-%     error('TODO').
-
-% t_get_rules(_) ->
-%     error('TODO').
-
-% t_get_resources(_) ->
-%     error('TODO').
-
-% t_remove_resource(_) ->
-%     error('TODO').
-
-% t_find_resource_params(_) ->
-%     error('TODO').
-
-% t_add_resource(_) ->
-%     error('TODO').
-
-% t_find_resource_type(_) ->
-%     error('TODO').
-
-% t_remove_rule(_) ->
-%     error('TODO').
-
-% t_add_rule(_) ->
-%     error('TODO').
-
-% t_register_resource_types(_) ->
-%     error('TODO').
-
-% t_add_actions(_) ->
-%     error('TODO').
-
-% t_unregister_resource_types_of(_) ->
-%     error('TODO').
-
-% t_remove_actions_of(_) ->
-%     error('TODO').
-
-% t_get_rule(_) ->
-%     error('TODO').
-
-% t_find_resource(_) ->
-%     error('TODO').
-