Add test cases for topic match

This commit is contained in:
HuangDan 2017-08-23 21:45:11 +08:00
parent 363928505a
commit 947df6ce35
2 changed files with 12 additions and 4 deletions

View File

@ -129,7 +129,6 @@ init_per_suite(Config) ->
NewConfig = generate_config(),
lists:foreach(fun set_app_env/1, NewConfig),
application:ensure_all_started(?APP),
timer:sleep(6000),
Config.
end_per_suite(_Config) ->
@ -590,8 +589,9 @@ conflict_listeners(_) ->
{current_clients, esockd:get_current_clients(Pid)},
{shutdown_count, esockd:get_shutdown_count(Pid)}]}
end, esockd:listeners()),
?assertEqual(1, proplists:get_value(current_clients, proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners))),
?assertEqual([{conflict,1}], proplists:get_value(shutdown_count, proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners))),
L =proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners),
?assertEqual(1, proplists:get_value(current_clients, L)),
?assertEqual(1, proplists:get_value(conflict, L)),
emqttc:disconnect(C2).
cli_vm(_) ->

View File

@ -26,7 +26,7 @@
-define(N, 10000).
all() -> [t_wildcard, t_match, t_match2, t_validate, t_triples, t_join,
all() -> [t_wildcard, t_match, t_match2, t_match3, t_validate, t_triples, t_join,
t_words, t_systop, t_feed_var, t_sys_match, 't_#_match',
t_sigle_level_validate, t_sigle_level_match, t_match_perf,
t_triples_perf, t_parse].
@ -71,6 +71,14 @@ t_match2(_) ->
false = match(<<"$shared/x/y">>, <<"+/+/#">>),
false = match(<<"house/1/sensor/0">>, <<"house/+">>).
t_match3(_) ->
true = match(<<"device/60019423a83c/fw">>, <<"device/60019423a83c/#">>),
false = match(<<"device/60019423a83c/$fw">>, <<"device/60019423a83c/#">>),
true = match(<<"device/60019423a83c/$fw/fw">>, <<"device/60019423a83c/$fw/#">>),
true = match(<<"device/60019423a83c/fw/checksum">>, <<"device/60019423a83c/#">>),
false = match(<<"device/60019423a83c/$fw/checksum">>, <<"device/60019423a83c/#">>),
true = match(<<"device/60019423a83c/dust/type">>, <<"device/60019423a83c/#">>).
t_sigle_level_match(_) ->
true = match(<<"sport/tennis/player1">>, <<"sport/tennis/+">>),
false = match(<<"sport/tennis/player1/ranking">>, <<"sport/tennis/+">>),