mirror of
https://github.com/valitydev/capi-v2.git
synced 2024-11-06 01:55:20 +00:00
TD-933: Fixes response serialization w/ randomized invoice amount (#50)
This commit is contained in:
parent
85b19cb5f3
commit
ea4e74b3c4
@ -67,7 +67,7 @@ decode_invoice_amount_mutation(Mutations) when is_list(Mutations) ->
|
||||
({amount, #domain_InvoiceAmountMutation{original = Original, mutated = Mutated}}, _) ->
|
||||
#{
|
||||
<<"original">> => Original,
|
||||
<<"mutated">> => Mutated
|
||||
<<"randomized">> => Mutated
|
||||
};
|
||||
(_, AmountRandomized) ->
|
||||
AmountRandomized
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
-export([
|
||||
create_invoice_ok_test/1,
|
||||
create_invoice_rand_amount_ok_test/1,
|
||||
create_invoice_autorization_error_test/1,
|
||||
get_invoice_by_external_id/1,
|
||||
get_invoice_by_external_id_for_party/1,
|
||||
@ -153,6 +154,7 @@ groups() ->
|
||||
create_customer_access_token_ok_test,
|
||||
|
||||
create_invoice_ok_test,
|
||||
create_invoice_rand_amount_ok_test,
|
||||
create_invoice_autorization_error_test,
|
||||
get_invoice_by_external_id,
|
||||
get_invoice_by_external_id_for_party,
|
||||
@ -307,6 +309,27 @@ create_invoice_ok_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_assert_shop_op_ctx(<<"CreateInvoice">>, ?STRING, ?STRING, Config),
|
||||
{ok, _} = capi_client_invoices:create_invoice(?config(context, Config), ?INVOICE_PARAMS).
|
||||
|
||||
-spec create_invoice_rand_amount_ok_test(config()) -> _.
|
||||
create_invoice_rand_amount_ok_test(Config) ->
|
||||
RandomizedAmount = ?INTEGER + ?SMALLER_INTEGER,
|
||||
ExpectedInvoice = ?INVOICE#domain_Invoice{
|
||||
cost = ?CASH(RandomizedAmount),
|
||||
mutations = [{amount, #domain_InvoiceAmountMutation{original = ?INTEGER, mutated = RandomizedAmount}}]
|
||||
},
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{invoicing, fun('Create', _) -> {ok, ?PAYPROC_INVOICE(ExpectedInvoice, [])} end},
|
||||
{generator, fun('GenerateID', _) -> capi_ct_helper_bender:generate_id(<<"bender_key">>) end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_shop_op_ctx(<<"CreateInvoice">>, ?STRING, ?STRING, Config),
|
||||
{ok, _} = capi_client_invoices:create_invoice(?config(context, Config), ?INVOICE_PARAMS#{
|
||||
<<"randomizeAmount">> => #{
|
||||
<<"deviation">> => ?SMALLER_INTEGER
|
||||
}
|
||||
}).
|
||||
|
||||
-spec create_invoice_autorization_error_test(config()) -> _.
|
||||
create_invoice_autorization_error_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
|
Loading…
Reference in New Issue
Block a user