|
70 | 70 | -export([batch_commit_ok/1]). |
71 | 71 | -export([batch_rollback_ok/1]). |
72 | 72 | -export([batch_rollback_lenient_to_config_notfound_ok/1]). |
| 73 | +-export([batch_get_values_lenient_to_config_notfound_ok/1]). |
| 74 | +-export([batch_hold_strict_to_config_notfound_ok/1]). |
73 | 75 | -export([two_batch_hold_ok/1]). |
74 | 76 | -export([two_batch_commit_ok/1]). |
75 | 77 | -export([two_batch_rollback_ok/1]). |
@@ -140,6 +142,8 @@ groups() -> |
140 | 142 | batch_commit_ok, |
141 | 143 | batch_rollback_ok, |
142 | 144 | batch_rollback_lenient_to_config_notfound_ok, |
| 145 | + batch_get_values_lenient_to_config_notfound_ok, |
| 146 | + batch_hold_strict_to_config_notfound_ok, |
143 | 147 | two_batch_hold_ok, |
144 | 148 | two_batch_commit_ok, |
145 | 149 | two_batch_rollback_ok, |
@@ -879,6 +883,10 @@ construct_request(C) -> |
879 | 883 | ?LIMIT_CHANGE(ID2, 0, Version2) |
880 | 884 | ]). |
881 | 885 |
|
| 886 | +add_non_existent_limit_config(?LIMIT_REQUEST(_ID, Changes) = Request) -> |
| 887 | + NonexistentChange = ?LIMIT_CHANGE(<<"this-does-not-exist">>, 0, dmt_client:get_last_version()), |
| 888 | + Request#limiter_LimitRequest{limit_changes = [NonexistentChange | Changes]}. |
| 889 | + |
882 | 890 | -spec batch_hold_ok(config()) -> _. |
883 | 891 | batch_hold_ok(C) -> |
884 | 892 | Context = |
@@ -922,15 +930,37 @@ batch_rollback_lenient_to_config_notfound_ok(C) -> |
922 | 930 | end, |
923 | 931 | Request0 = construct_request(C), |
924 | 932 | ok = hold_and_assert_batch(10, Request0, Context, C), |
925 | | - Request1 = Request0#limiter_LimitRequest{ |
926 | | - limit_changes = [ |
927 | | - ?LIMIT_CHANGE(<<"this-does-not-exist">>, 0, dmt_client:get_last_version()) |
928 | | - | Request0#limiter_LimitRequest.limit_changes |
929 | | - ] |
930 | | - }, |
| 933 | + Request1 = add_non_existent_limit_config(Request0), |
931 | 934 | {ok, ok} = lim_client:rollback_batch(Request1, Context, ?config(client, C)), |
932 | 935 | ok = assert_values(0, Request0, Context, C). |
933 | 936 |
|
| 937 | +-spec batch_get_values_lenient_to_config_notfound_ok(config()) -> _. |
| 938 | +batch_get_values_lenient_to_config_notfound_ok(C) -> |
| 939 | + Context = |
| 940 | + case get_group_name(C) of |
| 941 | + withdrawals -> ?wthdproc_ctx_withdrawal(?cash(10)); |
| 942 | + _Default -> ?payproc_ctx_payment(?cash(10), ?cash(10)) |
| 943 | + end, |
| 944 | + Request0 = construct_request(C), |
| 945 | + ok = hold_and_assert_batch(10, Request0, Context, C), |
| 946 | + Request1 = add_non_existent_limit_config(Request0), |
| 947 | + ok = assert_batch(10, Request1, Context, C), |
| 948 | + ok = assert_values(10, Request1, Context, C). |
| 949 | + |
| 950 | +-spec batch_hold_strict_to_config_notfound_ok(config()) -> _. |
| 951 | +batch_hold_strict_to_config_notfound_ok(C) -> |
| 952 | + Context = |
| 953 | + case get_group_name(C) of |
| 954 | + withdrawals -> ?wthdproc_ctx_withdrawal(?cash(10)); |
| 955 | + _Default -> ?payproc_ctx_payment(?cash(10), ?cash(10)) |
| 956 | + end, |
| 957 | + Request0 = construct_request(C), |
| 958 | + Request1 = add_non_existent_limit_config(Request0), |
| 959 | + ?assertEqual( |
| 960 | + {exception, #limiter_LimitNotFound{}}, |
| 961 | + lim_client:hold_batch(Request1, Context, ?config(client, C)) |
| 962 | + ). |
| 963 | + |
934 | 964 | -spec two_batch_hold_ok(config()) -> _. |
935 | 965 | two_batch_hold_ok(C) -> |
936 | 966 | Context = |
|
0 commit comments