Bläddra i källkod

fix(ft): set default ft config in tests

Ilya Averyanov 2 år sedan
förälder
incheckning
4a144044b7

+ 3 - 21
apps/emqx_ft/test/emqx_ft_conf_SUITE.erl

@@ -26,30 +26,12 @@ all() -> emqx_common_test_helpers:all(?MODULE).
 
 init_per_suite(Config) ->
     _ = emqx_config:save_schema_mod_and_names(emqx_ft_schema),
-    ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_ft], fun set_special_config/1),
+    ok = emqx_common_test_helpers:start_apps(
+        [emqx_conf, emqx_ft], emqx_ft_test_helpers:env_handler(Config)
+    ),
     {ok, _} = emqx:update_config([rpc, port_discovery], manual),
     Config.
 
-set_special_config(emqx_ft) ->
-    emqx_config:put(
-        [file_transfer],
-        #{
-            storage => #{
-                type => local,
-                segments => #{
-                    gc => #{
-                        interval => 60000
-                    }
-                },
-                exporter => #{
-                    type => local
-                }
-            }
-        }
-    );
-set_special_config(_) ->
-    ok.
-
 end_per_suite(_Config) ->
     ok = emqx_common_test_helpers:stop_apps([emqx_ft, emqx_conf]),
     ok.

+ 1 - 1
apps/emqx_ft/test/emqx_ft_responder_SUITE.erl

@@ -24,7 +24,7 @@
 all() -> emqx_common_test_helpers:all(?MODULE).
 
 init_per_suite(Config) ->
-    ok = emqx_common_test_helpers:start_apps([emqx_ft]),
+    ok = emqx_common_test_helpers:start_apps([emqx_ft], emqx_ft_test_helpers:env_handler(Config)),
     Config.
 
 end_per_suite(_Config) ->

+ 9 - 6
apps/emqx_ft/test/emqx_ft_test_helpers.erl

@@ -28,12 +28,7 @@ start_additional_node(Config, Name) ->
             {apps, [emqx_ft]},
             {join_to, node()},
             {configure_gen_rpc, true},
-            {env_handler, fun
-                (emqx_ft) ->
-                    load_config(#{storage => local_storage(Config)});
-                (_) ->
-                    ok
-            end}
+            {env_handler, env_handler(Config)}
         ]
     ).
 
@@ -43,6 +38,14 @@ stop_additional_node(Node) ->
     ok = emqx_common_test_helpers:stop_slave(Node),
     ok.
 
+env_handler(Config) ->
+    fun
+        (emqx_ft) ->
+            load_config(#{storage => local_storage(Config)});
+        (_) ->
+            ok
+    end.
+
 local_storage(Config) ->
     #{
         type => local,