test: fix test cases to work with new exctption

This commit is contained in:
Zaiming (Stone) Shi 2023-04-08 21:44:39 +02:00
parent 6969c2a670
commit 466a28daf2
3 changed files with 12 additions and 5 deletions

View File

@ -239,6 +239,10 @@ parse_spec_ref(Module, Path, Options) ->
%% better error message %% better error message
catch catch
error:Reason:Stacktrace -> error:Reason:Stacktrace ->
%% raise a new error with the same stacktrace.
%% it's a bug if this happens.
%% i.e. if a path is listed in the spec but the module doesn't
%% implement it or crashes when trying to build the schema.
erlang:raise( erlang:raise(
error, error,
#{mfa => {Module, schema, [Path]}, reason => Reason}, #{mfa => {Module, schema, [Path]}, reason => Reason},

View File

@ -307,8 +307,11 @@ t_nest_ref(_Config) ->
t_none_ref(_Config) -> t_none_ref(_Config) ->
Path = "/ref/none", Path = "/ref/none",
?assertThrow( ?assertError(
{error, #{mfa := {?MODULE, schema, [Path]}}}, #{
mfa := {?MODULE, schema, [Path]},
reason := function_clause
},
emqx_dashboard_swagger:parse_spec_ref(?MODULE, Path, #{}) emqx_dashboard_swagger:parse_spec_ref(?MODULE, Path, #{})
), ),
ok. ok.

View File

@ -277,11 +277,11 @@ t_bad_ref(_Config) ->
t_none_ref(_Config) -> t_none_ref(_Config) ->
Path = "/ref/none", Path = "/ref/none",
?assertThrow( ?assertError(
{error, #{ #{
mfa := {?MODULE, schema, ["/ref/none"]}, mfa := {?MODULE, schema, ["/ref/none"]},
reason := function_clause reason := function_clause
}}, },
validate(Path, #{}, []) validate(Path, #{}, [])
), ),
ok. ok.