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

ci: update test cases for influxdb bad_timestamp

Shawn 1 год назад
Родитель
Сommit
f32dc56e39

+ 4 - 2
apps/emqx_bridge_datalayers/test/emqx_bridge_datalayers_SUITE.erl

@@ -874,7 +874,9 @@ t_bad_timestamp(Config) ->
                         [
                             #{
                                 error := [
-                                    {error, {bad_timestamp, <<"bad_timestamp">>}}
+                                    {error,
+                                        {bad_timestamp,
+                                            {non_integer_timestamp, <<"bad_timestamp">>}}}
                                 ]
                             }
                         ],
@@ -883,7 +885,7 @@ t_bad_timestamp(Config) ->
                 {sync, false} ->
                     ?assertEqual(
                         {error, [
-                            {error, {bad_timestamp, <<"bad_timestamp">>}}
+                            {error, {bad_timestamp, {non_integer_timestamp, <<"bad_timestamp">>}}}
                         ]},
                         Return
                     );

+ 8 - 4
apps/emqx_bridge_influxdb/test/emqx_bridge_influxdb_SUITE.erl

@@ -915,6 +915,10 @@ t_tag_set_use_literal_value(Config) ->
     ?assertEqual(TsStr, TimeReturned).
 
 t_bad_timestamp(Config) ->
+    test_bad_timestamp(Config, <<"bad_timestamp">>, non_integer_timestamp),
+    test_bad_timestamp(Config, <<"${timestamp}000">>, unsupported_placeholder_usage_for_timestamp).
+
+test_bad_timestamp(Config, Timestamp, ErrTag) ->
     InfluxDBType = ?config(influxdb_type, Config),
     InfluxDBName = ?config(influxdb_name, Config),
     QueryMode = ?config(query_mode, Config),
@@ -929,7 +933,7 @@ t_bad_timestamp(Config) ->
         %% N.B.: this single space characters are relevant
         <<"${topic}", " ", "payload=${payload},", "${clientid}_int_value=${payload.int_key}i,",
             "uint_value=${payload.uint_key}u,"
-            "bool=${payload.bool}", " ", "bad_timestamp">>,
+            "bool=${payload.bool}", " ", Timestamp/binary>>,
     %% append this to override the config
     InfluxDBConfigString1 =
         io_lib:format(
@@ -983,16 +987,16 @@ t_bad_timestamp(Config) ->
                         [
                             #{
                                 error := [
-                                    {error, {bad_timestamp, <<"bad_timestamp">>}}
+                                    {error, {bad_timestamp, {ErrTag, _}}}
                                 ]
                             }
                         ],
                         ?of_kind(influxdb_connector_send_query_error, Trace)
                     );
                 {sync, false} ->
-                    ?assertEqual(
+                    ?assertMatch(
                         {error, [
-                            {error, {bad_timestamp, <<"bad_timestamp">>}}
+                            {error, {bad_timestamp, {ErrTag, _}}}
                         ]},
                         Return
                     );