fix: non-empty field should not be undefined
This commit is contained in:
parent
269a40a9ea
commit
f93c22045d
|
@ -161,12 +161,13 @@ t_lookups(_Config) ->
|
||||||
]
|
]
|
||||||
).
|
).
|
||||||
|
|
||||||
t_create_invalid(_Config) ->
|
%% should still succeed to create even if the config will not work,
|
||||||
|
%% because it's not a part of the schema check
|
||||||
|
t_create_with_config_values_wont_works(_Config) ->
|
||||||
AuthzConfig = raw_redis_authz_config(),
|
AuthzConfig = raw_redis_authz_config(),
|
||||||
|
|
||||||
InvalidConfigs =
|
InvalidConfigs =
|
||||||
[
|
[
|
||||||
maps:without([<<"server">>], AuthzConfig),
|
|
||||||
AuthzConfig#{<<"server">> => <<"unknownhost:3333">>},
|
AuthzConfig#{<<"server">> => <<"unknownhost:3333">>},
|
||||||
AuthzConfig#{<<"password">> => <<"wrongpass">>},
|
AuthzConfig#{<<"password">> => <<"wrongpass">>},
|
||||||
AuthzConfig#{<<"database">> => <<"5678">>}
|
AuthzConfig#{<<"database">> => <<"5678">>}
|
||||||
|
@ -180,6 +181,15 @@ t_create_invalid(_Config) ->
|
||||||
InvalidConfigs
|
InvalidConfigs
|
||||||
).
|
).
|
||||||
|
|
||||||
|
%% creating without a require filed should return error
|
||||||
|
t_create_invalid_schema(_Config) ->
|
||||||
|
AuthzConfig = raw_redis_authz_config(),
|
||||||
|
C = maps:without([<<"server">>], AuthzConfig),
|
||||||
|
?assertMatch(
|
||||||
|
{error, {emqx_conf_schema, _}},
|
||||||
|
emqx_authz:update(?CMD_REPLACE, [C])
|
||||||
|
).
|
||||||
|
|
||||||
t_redis_error(_Config) ->
|
t_redis_error(_Config) ->
|
||||||
ok = setup_config(#{<<"cmd">> => <<"INVALID COMMAND">>}),
|
ok = setup_config(#{<<"cmd">> => <<"INVALID COMMAND">>}),
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ min(Type, Min) ->
|
||||||
|
|
||||||
not_empty(ErrMsg) ->
|
not_empty(ErrMsg) ->
|
||||||
fun
|
fun
|
||||||
|
(undefined) -> {error, ErrMsg};
|
||||||
(<<>>) -> {error, ErrMsg};
|
(<<>>) -> {error, ErrMsg};
|
||||||
(_) -> ok
|
(_) -> ok
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue