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
catch
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(
error,
#{mfa => {Module, schema, [Path]}, reason => Reason},

View File

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

View File

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