test(ds): avoid introducing new macros

This commit is contained in:
Andrew Mayorov 2024-03-07 16:48:33 +01:00
parent 69427dc42d
commit f7e3afde16
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 16 additions and 31 deletions

View File

@ -83,27 +83,6 @@
end)()
).
-define(assertMatchOneOf(PAT1, PAT2, EXPR),
(fun() ->
case (X__V = (EXPR)) of
PAT1 ->
X__V;
PAT2 ->
X__V;
_ ->
erlang:error(
{assertMatch, [
{module, ?MODULE},
{line, ?LINE},
{expression, (??EXPR)},
{pattern, "one of [ " ++ (??PAT1) ++ ", " ++ (??PAT2) ++ " ]"},
{value, X__V}
]}
)
end
end)()
).
-define(assertExceptionOneOf(CT1, CT2, EXPR),
(fun() ->
X__Attrs = [

View File

@ -610,11 +610,14 @@ t_error_mapping_replication_layer(_Config) ->
%% At least one of `emqx_ds:make_iterator/4` will end in an error.
Results1 = lists:map(
fun({_Rank, S}) ->
?assertMatchOneOf(
{ok, _Iter},
{error, recoverable, {erpc, _}},
emqx_ds:make_iterator(DB, S, TopicFilter, 0)
)
case emqx_ds:make_iterator(DB, S, TopicFilter, 0) of
Ok = {ok, _Iter} ->
Ok;
Error = {error, recoverable, {erpc, _}} ->
Error;
Other ->
ct:fail({unexpected_result, Other})
end
end,
Streams0
),
@ -626,11 +629,14 @@ t_error_mapping_replication_layer(_Config) ->
%% At least one of `emqx_ds:next/3` over initial set of iterators will end in an error.
Results2 = lists:map(
fun(Iter) ->
?assertMatchOneOf(
{ok, _Iter, [_ | _]},
{error, recoverable, {badrpc, _}},
emqx_ds:next(DB, Iter, _BatchSize = 42)
)
case emqx_ds:next(DB, Iter, _BatchSize = 42) of
Ok = {ok, _Iter, [_ | _]} ->
Ok;
Error = {error, recoverable, {badrpc, _}} ->
Error;
Other ->
ct:fail({unexpected_result, Other})
end
end,
Iterators0
),