diff --git a/apps/emqx/test/emqx_inflight_SUITE.erl b/apps/emqx/test/emqx_inflight_SUITE.erl index a819e788b..6e5d8f5cc 100644 --- a/apps/emqx/test/emqx_inflight_SUITE.erl +++ b/apps/emqx/test/emqx_inflight_SUITE.erl @@ -20,10 +20,9 @@ -compile(nowarn_export_all). -include_lib("eunit/include/eunit.hrl"). --include_lib("emqx_ct_helpers/include/emqx_ct.hrl"). all() -> emqx_ct:all(?MODULE). - + t_contain(_) -> Inflight = emqx_inflight:insert(k, v, emqx_inflight:new()), ?assert(emqx_inflight:contain(k, Inflight)), @@ -41,12 +40,12 @@ t_insert(_) -> ?assertEqual(2, emqx_inflight:size(Inflight)), ?assertEqual({value, 1}, emqx_inflight:lookup(a, Inflight)), ?assertEqual({value, 2}, emqx_inflight:lookup(b, Inflight)), - ?catch_error({key_exists, a}, emqx_inflight:insert(a, 1, Inflight)). + ?assertError({key_exists, a}, emqx_inflight:insert(a, 1, Inflight)). t_update(_) -> Inflight = emqx_inflight:insert(k, v, emqx_inflight:new()), ?assertEqual(Inflight, emqx_inflight:update(k, v, Inflight)), - ?catch_error(function_clause, emqx_inflight:update(badkey, v, Inflight)). + ?assertError(function_clause, emqx_inflight:update(badkey, v, Inflight)). t_resize(_) -> Inflight = emqx_inflight:insert(k, v, emqx_inflight:new(2)), diff --git a/apps/emqx/test/emqx_mqtt_props_SUITE.erl b/apps/emqx/test/emqx_mqtt_props_SUITE.erl index 2e96182b0..b4dcd2f18 100644 --- a/apps/emqx/test/emqx_mqtt_props_SUITE.erl +++ b/apps/emqx/test/emqx_mqtt_props_SUITE.erl @@ -21,7 +21,6 @@ -include_lib("emqx/include/emqx_mqtt.hrl"). -include_lib("eunit/include/eunit.hrl"). --include_lib("emqx_ct_helpers/include/emqx_ct.hrl"). all() -> emqx_ct:all(?MODULE). @@ -30,14 +29,14 @@ t_id(_) -> fun({Id, Prop}) -> ?assertEqual(Id, emqx_mqtt_props:id(element(1, Prop))) end), - ?catch_error({bad_property, 'Bad-Property'}, emqx_mqtt_props:id('Bad-Property')). + ?assertError({bad_property, 'Bad-Property'}, emqx_mqtt_props:id('Bad-Property')). t_name(_) -> foreach_prop( fun({Id, Prop}) -> ?assertEqual(emqx_mqtt_props:name(Id), element(1, Prop)) end), - ?catch_error({unsupported_property, 16#FF}, emqx_mqtt_props:name(16#FF)). + ?assertError({unsupported_property, 16#FF}, emqx_mqtt_props:name(16#FF)). t_filter(_) -> ConnProps = #{'Session-Expiry-Interval' => 1, @@ -60,7 +59,7 @@ t_validate(_) -> }, ok = emqx_mqtt_props:validate(ConnProps), BadProps = #{'Unknown-Property' => 10}, - ?catch_error({bad_property,'Unknown-Property'}, + ?assertError({bad_property,'Unknown-Property'}, emqx_mqtt_props:validate(BadProps)). t_validate_value(_) -> @@ -68,11 +67,11 @@ t_validate_value(_) -> ok = emqx_mqtt_props:validate(#{'Reason-String' => <<"Unknown Reason">>}), ok = emqx_mqtt_props:validate(#{'User-Property' => {<<"Prop">>, <<"Val">>}}), ok = emqx_mqtt_props:validate(#{'User-Property' => [{<<"Prop">>, <<"Val">>}]}), - ?catch_error({bad_property_value, {'Payload-Format-Indicator', 16#FFFF}}, + ?assertError({bad_property_value, {'Payload-Format-Indicator', 16#FFFF}}, emqx_mqtt_props:validate(#{'Payload-Format-Indicator' => 16#FFFF})), - ?catch_error({bad_property_value, {'Server-Keep-Alive', 16#FFFFFF}}, + ?assertError({bad_property_value, {'Server-Keep-Alive', 16#FFFFFF}}, emqx_mqtt_props:validate(#{'Server-Keep-Alive' => 16#FFFFFF})), - ?catch_error({bad_property_value, {'Will-Delay-Interval', -16#FF}}, + ?assertError({bad_property_value, {'Will-Delay-Interval', -16#FF}}, emqx_mqtt_props:validate(#{'Will-Delay-Interval' => -16#FF})). foreach_prop(Fun) -> @@ -86,4 +85,4 @@ foreach_prop(Fun) -> % error('TODO'). % t_get(_) -> -% error('TODO'). \ No newline at end of file +% error('TODO'). diff --git a/apps/emqx/test/emqx_topic_SUITE.erl b/apps/emqx/test/emqx_topic_SUITE.erl index 0cccb74bb..e8262a8ec 100644 --- a/apps/emqx/test/emqx_topic_SUITE.erl +++ b/apps/emqx/test/emqx_topic_SUITE.erl @@ -20,7 +20,6 @@ -compile(nowarn_export_all). -include_lib("eunit/include/eunit.hrl"). --include_lib("emqx_ct_helpers/include/emqx_ct.hrl"). -import(emqx_topic, [ wildcard/1 @@ -126,21 +125,21 @@ t_validate(_) -> true = validate({filter, <<"abc/#">>}), true = validate({filter, <<"x">>}), true = validate({name, <<"x//y">>}), - true = validate({filter, <<"sport/tennis/#">>}), - ok = ?catch_error(empty_topic, validate({name, <<>>})), - ok = ?catch_error(topic_name_error, validate({name, <<"abc/#">>})), - ok = ?catch_error(topic_too_long, validate({name, long_topic()})), - ok = ?catch_error('topic_invalid_#', validate({filter, <<"abc/#/1">>})), - ok = ?catch_error(topic_invalid_char, validate({filter, <<"abc/#xzy/+">>})), - ok = ?catch_error(topic_invalid_char, validate({filter, <<"abc/xzy/+9827">>})), - ok = ?catch_error(topic_invalid_char, validate({filter, <<"sport/tennis#">>})), - ok = ?catch_error('topic_invalid_#', validate({filter, <<"sport/tennis/#/ranking">>})). + true = validate({filter, <<"sport/tennis/#">>}), + ?assertError(empty_topic, validate({name, <<>>})), + ?assertError(topic_name_error, validate({name, <<"abc/#">>})), + ?assertError(topic_too_long, validate({name, long_topic()})), + ?assertError('topic_invalid_#', validate({filter, <<"abc/#/1">>})), + ?assertError(topic_invalid_char, validate({filter, <<"abc/#xzy/+">>})), + ?assertError(topic_invalid_char, validate({filter, <<"abc/xzy/+9827">>})), + ?assertError(topic_invalid_char, validate({filter, <<"sport/tennis#">>})), + ?assertError('topic_invalid_#', validate({filter, <<"sport/tennis/#/ranking">>})). t_sigle_level_validate(_) -> true = validate({filter, <<"+">>}), true = validate({filter, <<"+/tennis/#">>}), true = validate({filter, <<"sport/+/player1">>}), - ok = ?catch_error(topic_invalid_char, validate({filter, <<"sport+">>})). + ?assertError(topic_invalid_char, validate({filter, <<"sport+">>})). t_prepend(_) -> ?assertEqual(<<"ab">>, prepend(undefined, <<"ab">>)), @@ -192,14 +191,14 @@ long_topic() -> iolist_to_binary([[integer_to_list(I), "/"] || I <- lists:seq(0, 66666)]). t_parse(_) -> - ok = ?catch_error({invalid_topic_filter, <<"$queue/t">>}, - parse(<<"$queue/t">>, #{share => <<"g">>})), - ok = ?catch_error({invalid_topic_filter, <<"$share/g/t">>}, - parse(<<"$share/g/t">>, #{share => <<"g">>})), - ok = ?catch_error({invalid_topic_filter, <<"$share/t">>}, - parse(<<"$share/t">>)), - ok = ?catch_error({invalid_topic_filter, <<"$share/+/t">>}, - parse(<<"$share/+/t">>)), + ?assertError({invalid_topic_filter, <<"$queue/t">>}, + parse(<<"$queue/t">>, #{share => <<"g">>})), + ?assertError({invalid_topic_filter, <<"$share/g/t">>}, + parse(<<"$share/g/t">>, #{share => <<"g">>})), + ?assertError({invalid_topic_filter, <<"$share/t">>}, + parse(<<"$share/t">>)), + ?assertError({invalid_topic_filter, <<"$share/+/t">>}, + parse(<<"$share/+/t">>)), ?assertEqual({<<"a/b/+/#">>, #{}}, parse(<<"a/b/+/#">>)), ?assertEqual({<<"a/b/+/#">>, #{qos => 1}}, parse({<<"a/b/+/#">>, #{qos => 1}})), ?assertEqual({<<"topic">>, #{share => <<"$queue">>}}, parse(<<"$queue/topic">>)),