test: make schema test happy
This commit is contained in:
parent
5be4d97c42
commit
ee2847dcd9
|
@ -2664,7 +2664,7 @@ servers_validator(Opts, Required) ->
|
|||
case str(Str0) of
|
||||
"" ->
|
||||
%% Empty string is not allowed even if the field is not required
|
||||
%% remove field from config if it's empty
|
||||
%% we should remove field from config if it's empty
|
||||
throw("cannot_be_empty");
|
||||
"undefined" when Required ->
|
||||
%% when the filed is not set in config file
|
||||
|
|
|
@ -1243,8 +1243,8 @@ session(InitFields) when is_map(InitFields) ->
|
|||
),
|
||||
Session = emqx_session:init(Conf),
|
||||
maps:fold(
|
||||
fun(Field, Value, Session) ->
|
||||
emqx_session:set_field(Field, Value, Session)
|
||||
fun(Field, Value, SessionAcc) ->
|
||||
emqx_session:set_field(Field, Value, SessionAcc)
|
||||
end,
|
||||
Session,
|
||||
InitFields
|
||||
|
|
|
@ -455,10 +455,11 @@ servers_validator_test() ->
|
|||
NotRequired = emqx_schema:servers_validator(#{}, false),
|
||||
?assertThrow("cannot_be_empty", Required("")),
|
||||
?assertThrow("cannot_be_empty", Required(<<>>)),
|
||||
?assertThrow("cannot_be_empty", NotRequired("")),
|
||||
?assertThrow("cannot_be_empty", NotRequired(<<>>)),
|
||||
?assertThrow("cannot_be_empty", Required(undefined)),
|
||||
?assertEqual(ok, NotRequired("")),
|
||||
?assertEqual(ok, NotRequired(<<>>)),
|
||||
?assertEqual(ok, NotRequired(undefined)),
|
||||
?assertEqual(ok, NotRequired("undefined")),
|
||||
ok.
|
||||
|
||||
converter_invalid_input_test() ->
|
||||
|
|
|
@ -471,8 +471,8 @@ session(InitFields) when is_map(InitFields) ->
|
|||
),
|
||||
Session = emqx_session:init(Conf),
|
||||
maps:fold(
|
||||
fun(Field, Value, Session) ->
|
||||
emqx_session:set_field(Field, Value, Session)
|
||||
fun(Field, Value, SessionAcc) ->
|
||||
emqx_session:set_field(Field, Value, SessionAcc)
|
||||
end,
|
||||
Session,
|
||||
InitFields
|
||||
|
|
Loading…
Reference in New Issue