From 9a249e4b01fc9ab717a1ab02c0a5db255fa87989 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 14 Aug 2023 13:11:25 +0400 Subject: [PATCH] test(topicidx): increase test coverage --- apps/emqx/test/emqx_topic_index_SUITE.erl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/emqx/test/emqx_topic_index_SUITE.erl b/apps/emqx/test/emqx_topic_index_SUITE.erl index 80ca536b4..ade98acec 100644 --- a/apps/emqx/test/emqx_topic_index_SUITE.erl +++ b/apps/emqx/test/emqx_topic_index_SUITE.erl @@ -141,6 +141,7 @@ t_match_fast_forward(_) -> % dbg:tracer(), % dbg:p(all, c), % dbg:tpl({ets, next, '_'}, x), + ?assertEqual(id1, id(match(<<"a/b/1/2/3/4/5/6/7/8/9/0">>, Tab))), ?assertEqual([id1], [id(M) || M <- matches(<<"a/b/1/2/3/4/5/6/7/8/9/0">>, Tab)]). t_match_unique(_) -> @@ -180,14 +181,15 @@ t_match_wildcard_edge_cases(_) -> F = fun({Topics, TopicName, Expected}) -> Tab = emqx_topic_index:new(), _ = [emqx_topic_index:insert(T, N, <<>>, Tab) || {N, T} <- lists:enumerate(Topics)], - Results = [id(M) || M <- emqx_topic_index:matches(TopicName, Tab, [unique])], + ?assertEqual( + lists:last(Expected), + id(emqx_topic_index:match(TopicName, Tab)), + #{"Base topics" => Topics, "Topic name" => TopicName} + ), ?assertEqual( Expected, - Results, - #{ - "Base topics" => Topics, - "Topic name" => TopicName - } + [id(M) || M <- emqx_topic_index:matches(TopicName, Tab, [unique])], + #{"Base topics" => Topics, "Topic name" => TopicName} ) end, lists:foreach(F, Datasets).