fix: retry not_found if conf file not exist
This commit is contained in:
parent
1ad02a11e2
commit
083537daa3
|
@ -312,8 +312,14 @@ get_config(Key) ->
|
|||
load_config(Path, Opts) when is_list(Path) ->
|
||||
case hocon:files([Path]) of
|
||||
{ok, RawConf} when RawConf =:= #{} ->
|
||||
emqx_ctl:warning("load ~ts is empty~n", [Path]),
|
||||
{error, empty_hocon_file};
|
||||
case filelib:is_file(Path) of
|
||||
true ->
|
||||
emqx_ctl:warning("load ~ts is empty~n", [Path]),
|
||||
{error, empty_hocon_file};
|
||||
false ->
|
||||
emqx_ctl:warning("~ts is not found~n", [Path]),
|
||||
{error, not_found_hocon_file}
|
||||
end;
|
||||
{ok, RawConf} ->
|
||||
load_config_from_raw(RawConf, Opts);
|
||||
{error, Reason} ->
|
||||
|
|
|
@ -81,7 +81,11 @@ t_load_config(Config) ->
|
|||
Conf#{<<"sources">> => [emqx_authz_schema:default_authz()]},
|
||||
emqx_conf:get_raw([Authz])
|
||||
),
|
||||
?assertEqual({error, empty_hocon_file}, emqx_conf_cli:conf(["load", "non-exist-file"])),
|
||||
?assertEqual({error, not_found_hocon_file}, emqx_conf_cli:conf(["load", "non-exist-file"])),
|
||||
EmptyFile = "empty_file.conf",
|
||||
ok = file:write_file(EmptyFile, <<>>),
|
||||
?assertEqual({error, empty_hocon_file}, emqx_conf_cli:conf(["load", EmptyFile])),
|
||||
ok = file:delete(EmptyFile),
|
||||
ok.
|
||||
|
||||
t_conflict_mix_conf(Config) ->
|
||||
|
|
Loading…
Reference in New Issue