TD-266: Fix - empty invoice id field (#17)

* fixed empty invoice id bug

* fixed

* fixed
This commit is contained in:
Артем 2022-07-25 14:11:34 +03:00 committed by GitHub
parent 9e3f8eb930
commit b8544b7cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 1 deletions

View File

@ -61,7 +61,7 @@ make_query(payments, Context, Req) ->
#magista_PaymentSearchQuery{
common_search_query_params = CommonSearchQueryParams,
payment_params = PaymentParams,
invoice_ids = [genlib_map:get('invoiceID', Req)]
invoice_ids = genlib_list:wrap(genlib_map:get('invoiceID', Req))
}.
process_search_request(QueryType, Query, _Req, Context, Opts = #{thrift_fun := ThriftFun}) ->

View File

@ -100,6 +100,12 @@
payment = ?CTX_ENTITY(PaymentID)
}).
-define(CTX_SEARCH_PAYMENT_OP(ID, PartyID, ShopID), #ctx_v1_CommonAPIOperation{
id = ID,
party = ?CTX_ENTITY(PartyID),
shop = ?CTX_ENTITY(ShopID)
}).
-define(CTX_SEARCH_PAYOUT_OP(ID, PartyID, ShopID, PayoutID), #ctx_v1_CommonAPIOperation{
id = ID,
party = ?CTX_ENTITY(PartyID),

View File

@ -21,6 +21,7 @@
-export([mock_assert_webhook_op_ctx/4]).
-export([mock_assert_payout_op_ctx/6]).
-export([mock_assert_search_invoice_op_ctx/7]).
-export([mock_assert_search_payment_op_ctx/4]).
-export([mock_assert_search_payment_op_ctx/6]).
-export([mock_assert_search_payout_op_ctx/5]).
-export([mock_assert_search_refund_op_ctx/7]).
@ -199,6 +200,22 @@ mock_assert_payout_op_ctx(Op, PayoutID, PartyID, ContractID, ShopID, Config) ->
Config
).
-spec mock_assert_search_payment_op_ctx(_, _, _, _) -> _.
mock_assert_search_payment_op_ctx(Op, PartyID, ShopID, Config) ->
SearchCtx = ?CTX_SEARCH_PAYMENT_OP(
Op,
PartyID,
ShopID
),
mock_arbiter(
?assertContextMatches(
#ctx_v1_ContextFragment{
capi = ?CTX_CAPI(SearchCtx)
}
),
Config
).
-spec mock_assert_search_payment_op_ctx(_, _, _, _, _, _) -> _.
mock_assert_search_payment_op_ctx(Op, PartyID, ShopID, InvoiceID, PaymentID, Config) ->
SearchCtx = ?CTX_SEARCH_PAYMENT_OP(

View File

@ -21,6 +21,7 @@
-export([init/1]).
-export([
search_payments_without_all_optional_fields_ok_test/1,
search_payments_ok_test/1,
search_payments_invalid_request_test/1,
search_payments_invalid_token_test/1,
@ -54,6 +55,7 @@ groups() ->
{group, operations_by_any_token}
]},
{operations_by_any_token, [], [
search_payments_without_all_optional_fields_ok_test,
search_payments_ok_test,
search_payments_invalid_request_test,
search_payments_invalid_token_test,
@ -107,6 +109,28 @@ end_per_testcase(_Name, C) ->
%%% Tests
-spec search_payments_without_all_optional_fields_ok_test(config()) -> _.
search_payments_without_all_optional_fields_ok_test(Config) ->
_ = capi_ct_helper:mock_services(
[
capi_test_hack:get_invoice_mock(),
{magista, fun('SearchPayments', _) -> {ok, ?STAT_RESPONSE_PAYMENTS} end}
],
Config
),
_ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx(
<<"SearchPayments">>,
?STRING,
?STRING,
Config
),
Query = [
{limit, 2},
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
{to_time, {{2020, 08, 11}, {19, 42, 35}}}
],
{ok, _, _} = capi_client_searches:search_payments(?config(context, Config), ?STRING, Query).
-spec search_payments_ok_test(config()) -> _.
search_payments_ok_test(Config) ->
_ = capi_ct_helper:mock_services(