test: allow missing schema for app in tests

This commit is contained in:
Zaiming (Stone) Shi 2022-07-19 20:13:54 +02:00
parent 256cdd50ff
commit 050f68cf5d
1 changed files with 9 additions and 3 deletions

View File

@ -181,11 +181,15 @@ start_app(App, Handler) ->
app_conf_file(emqx_conf) -> "emqx.conf.all"; app_conf_file(emqx_conf) -> "emqx.conf.all";
app_conf_file(App) -> atom_to_list(App) ++ ".conf". app_conf_file(App) -> atom_to_list(App) ++ ".conf".
%% TODO: get rid of cuttlefish
app_schema(App) -> app_schema(App) ->
Mod = list_to_atom(atom_to_list(App) ++ "_schema"), Mod = list_to_atom(atom_to_list(App) ++ "_schema"),
try
true = is_list(Mod:roots()), true = is_list(Mod:roots()),
Mod. Mod
catch
error:undef ->
no_schema
end.
mustache_vars(App) -> mustache_vars(App) ->
[ [
@ -221,6 +225,8 @@ render_config_file(ConfigFile, Vars0) ->
ok = file:write_file(NewName, Targ), ok = file:write_file(NewName, Targ),
NewName. NewName.
read_schema_configs(no_schema, _ConfigFile) ->
ok;
read_schema_configs(Schema, ConfigFile) -> read_schema_configs(Schema, ConfigFile) ->
NewConfig = generate_config(Schema, ConfigFile), NewConfig = generate_config(Schema, ConfigFile),
lists:foreach( lists:foreach(