Skip to content

Commit

Permalink
added limits tests for the tristate_integer cases (2600hz#5696)
Browse files Browse the repository at this point in the history
fixed limits test

fixed weird atomic spaces
  • Loading branch information
swysor authored and jamesaimonetti committed Apr 22, 2019
1 parent 900d0d0 commit 758fcfa
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions core/kazoo_documents/test/kzd_limits_tests.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
%%%-----------------------------------------------------------------------------
%%% @copyright (C) 2010-2019, 2600Hz
%%% @doc Limits document: tests
%%% @author Sean Wysor
%%% @end
%%%-----------------------------------------------------------------------------
-module(kzd_limits_tests).

-include_lib("eunit/include/eunit.hrl").

-define(DOC, kz_json:set_values([{<<"allow_postpay">>, 'false'}
,{<<"allow_prepay">>, 'true'}
,{<<"authz_resource_type">>, []}
,{<<"burst_trunks">>, 0}
,{<<"calls">>, 4}
,{<<"enabled">>, 'true'}
,{<<"inbound_trunks">>, 0}
,{<<"max_postpay_account">>, 0}
,{<<"outbound_trunks">>, 0}
,{<<"reserve_amount">>, 0}
,{<<"resource_consuming_calls">>, 4}
,{<<"soft_limit_inbound">>, 'false'}
,{<<"soft_limit_outbound">>, 'false'}
]
,kz_json:new()
)
).
-define(EMPTY, kz_json:new()).

-spec calls_test_() -> 'ok'.
calls_test_() ->
[?_assertEqual(4, kzd_limits:calls(?DOC))
,?_assertEqual(4, kzd_limits:calls(kzd_limits:set_pvt_calls(?DOC, -1)))
,?_assertEqual(10, kzd_limits:calls(kz_json:delete_key(<<"calls">>, kzd_limits:set_pvt_calls(?DOC, 10))))
,?_assertEqual(-1, kzd_limits:calls(kz_json:delete_key(<<"calls">>, ?DOC)))
,?_assertEqual(5, kzd_limits:calls(kzd_limits:set_calls(kzd_limits:set_pvt_calls(?DOC, 10), 5)))
,?_assertEqual(5, kzd_limits:calls(kzd_limits:set_calls(kzd_limits:set_pvt_calls(?DOC, 5), 10)))
].

-spec resource_consuming_calls_test_() -> 'ok'.
resource_consuming_calls_test_() ->
[?_assertEqual(4, kzd_limits:resource_consuming_calls(?DOC))
,?_assertEqual(4, kzd_limits:resource_consuming_calls(kzd_limits:set_pvt_resource_consuming_calls(?DOC, -1)))
,?_assertEqual(10, kzd_limits:resource_consuming_calls(kz_json:delete_key(<<"resource_consuming_calls">>, kzd_limits:set_pvt_resource_consuming_calls(?DOC, 10))))
,?_assertEqual(-1, kzd_limits:resource_consuming_calls(kz_json:delete_key(<<"resource_consuming_calls">>, ?DOC)))
,?_assertEqual(5, kzd_limits:resource_consuming_calls(kzd_limits:set_resource_consuming_calls(kzd_limits:set_pvt_resource_consuming_calls(?DOC, 10), 5)))
,?_assertEqual(5, kzd_limits:resource_consuming_calls(kzd_limits:set_resource_consuming_calls(kzd_limits:set_pvt_resource_consuming_calls(?DOC, 5), 10)))
].

0 comments on commit 758fcfa

Please sign in to comment.