test(emqx_modules): do not expect badmatch in test cases!!!
This commit is contained in:
parent
0ce1ca89b7
commit
981f75dc73
|
@ -1,7 +1,7 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_modules, [
|
{application, emqx_modules, [
|
||||||
{description, "EMQX Modules"},
|
{description, "EMQX Modules"},
|
||||||
{vsn, "5.0.8"},
|
{vsn, "5.0.9"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{applications, [kernel, stdlib, emqx]},
|
{applications, [kernel, stdlib, emqx]},
|
||||||
{mod, {emqx_modules_app, []}},
|
{mod, {emqx_modules_app, []}},
|
||||||
|
|
|
@ -88,8 +88,13 @@ regular_expression(_) -> undefined.
|
||||||
|
|
||||||
is_re(Bin) ->
|
is_re(Bin) ->
|
||||||
case re:compile(Bin) of
|
case re:compile(Bin) of
|
||||||
{ok, _} -> ok;
|
{ok, _} ->
|
||||||
{error, Reason} -> {error, {Bin, Reason}}
|
ok;
|
||||||
|
{error, Reason} ->
|
||||||
|
{error, #{
|
||||||
|
regexp => Bin,
|
||||||
|
compile_error => Reason
|
||||||
|
}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
array(Name, Meta) -> {Name, ?HOCON(?ARRAY(?R_REF(Name)), Meta)}.
|
array(Name, Meta) -> {Name, ?HOCON(?ARRAY(?R_REF(Name)), Meta)}.
|
||||||
|
|
|
@ -67,8 +67,12 @@ list() ->
|
||||||
emqx_conf:get_raw([<<"rewrite">>], []).
|
emqx_conf:get_raw([<<"rewrite">>], []).
|
||||||
|
|
||||||
update(Rules0) ->
|
update(Rules0) ->
|
||||||
{ok, _} = emqx_conf:update([rewrite], Rules0, #{override_to => cluster}),
|
case emqx_conf:update([rewrite], Rules0, #{override_to => cluster}) of
|
||||||
ok.
|
{ok, _} ->
|
||||||
|
ok;
|
||||||
|
{error, Reason} ->
|
||||||
|
throw(Reason)
|
||||||
|
end.
|
||||||
|
|
||||||
post_config_update(_KeyPath, _Config, Rules, _OldConf, _AppEnvs) ->
|
post_config_update(_KeyPath, _Config, Rules, _OldConf, _AppEnvs) ->
|
||||||
register_hook(Rules).
|
register_hook(Rules).
|
||||||
|
|
|
@ -215,16 +215,16 @@ t_update_re_failed(_Config) ->
|
||||||
<<"action">> => <<"publish">>
|
<<"action">> => <<"publish">>
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
?assertError(
|
?assertThrow(
|
||||||
{badmatch,
|
|
||||||
{error,
|
|
||||||
{_, [
|
|
||||||
#{
|
#{
|
||||||
kind := validation_error,
|
kind := validation_error,
|
||||||
reason := {Re, {"nothing to repeat", 0}},
|
path := "rewrite.1.re",
|
||||||
value := Re
|
reason := #{
|
||||||
}
|
regexp := <<"*^test/*">>,
|
||||||
]}}},
|
compile_error := {"nothing to repeat", 0}
|
||||||
|
},
|
||||||
|
value := <<"*^test/*">>
|
||||||
|
},
|
||||||
emqx_rewrite:update(Rules)
|
emqx_rewrite:update(Rules)
|
||||||
),
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
Loading…
Reference in New Issue