-
Notifications
You must be signed in to change notification settings - Fork 0
XYZ-451: Adds for arbitrary reason_code in general failure
#10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f5fc7ce
d374670
f09631e
3c3381b
9640b25
2678fdd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| OTP_VERSION=24.3.4 | ||
| REBAR_VERSION=3.18 | ||
| OTP_VERSION=28.5.0 | ||
| REBAR_VERSION=3.26 | ||
| THRIFT_VERSION=0.14.2.3 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| rebar 3.26.0 | ||
| erlang 28.5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| [{<<"damsel">>, | ||
| {git,"https://github.com/valitydev/damsel.git", | ||
| {ref,"dac2cb599499cc0701e60856f4092c9ab283eedf"}}, | ||
| {ref,"61e7a831b19b47284a1bd2fdd9cd12bfefb5e306"}}, | ||
| 0}]. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,9 @@ | |
| -export([known_error_test/1]). | ||
| -export([unknown_error_test/1]). | ||
| -export([unknown_error_atom_test/1]). | ||
| -export([general_failure_with_reason_code_test/1]). | ||
| -export([general_failure_with_reason_code_existing_atom_test/1]). | ||
| -export([general_failure_reason_code_notation_test/1]). | ||
| -export([bad_static_type_test/1]). | ||
| -export([formatting_test/1]). | ||
| -export([from_notation_test/1]). | ||
|
|
@@ -25,6 +28,9 @@ all() -> | |
| known_error_test, | ||
| unknown_error_test, | ||
| unknown_error_atom_test, | ||
| general_failure_with_reason_code_test, | ||
| general_failure_with_reason_code_existing_atom_test, | ||
| general_failure_reason_code_notation_test, | ||
| bad_static_type_test, | ||
| formatting_test, | ||
| from_notation_test, | ||
|
|
@@ -72,6 +78,58 @@ unknown_error_test(_C) -> | |
| DE = payproc_errors:construct('PaymentFailure', SE), | ||
| ok = payproc_errors:match('PaymentFailure', DE, fun(E) when SE =:= E -> ok end). | ||
|
|
||
| -spec general_failure_with_reason_code_test(config()) -> _. | ||
| general_failure_with_reason_code_test(_C) -> | ||
| DE = #domain_Failure{ | ||
| code = <<"no_route_found">>, | ||
| sub = #domain_SubFailure{ | ||
| code = <<"rejected">>, | ||
| sub = #domain_SubFailure{ | ||
| code = <<"limit_overflow">>, | ||
| sub = #domain_SubFailure{ | ||
| code = <<"limit-that-overflowed">> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это строка и так никогда атомом стать не сможет, давай какой-то существующий атом в отдельный тест.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавил тесткейс с этим случаем. Там трансляция из динамической в статическую происходит по кодпасу дающему |
||
| } | ||
| } | ||
| } | ||
| }, | ||
| SE = | ||
| {no_route_found, | ||
| {rejected, {limit_overflow, #payproc_error_GeneralFailure{reason_code = <<"limit-that-overflowed">>}}}}, | ||
| DE = payproc_errors:construct('PaymentFailure', SE), | ||
| ok = payproc_errors:match('PaymentFailure', DE, fun(E) when SE =:= E -> ok end). | ||
|
|
||
| -spec general_failure_with_reason_code_existing_atom_test(config()) -> _. | ||
| general_failure_with_reason_code_existing_atom_test(_C) -> | ||
| %% Ensures atom exists | ||
| _ = 'Code existing as atom', | ||
| DE = #domain_Failure{ | ||
| code = <<"no_route_found">>, | ||
| sub = #domain_SubFailure{ | ||
| code = <<"rejected">>, | ||
| sub = #domain_SubFailure{ | ||
| code = <<"limit_overflow">>, | ||
| sub = #domain_SubFailure{ | ||
| code = <<"Code existing as atom">> | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| SE = | ||
| {no_route_found, | ||
| {rejected, {limit_overflow, #payproc_error_GeneralFailure{reason_code = <<"Code existing as atom">>}}}}, | ||
| DE = payproc_errors:construct('PaymentFailure', SE), | ||
| ok = payproc_errors:match('PaymentFailure', DE, fun(E) when SE =:= E -> ok end). | ||
|
|
||
| -spec general_failure_reason_code_notation_test(config()) -> _. | ||
| general_failure_reason_code_notation_test(_C) -> | ||
| %% NOTE Notation is what downstream cascade and transient error matching | ||
| %% keys off, so an arbitrary reason code has to survive the | ||
| %% dynamic -> static -> dynamic round trip that `format/2` performs. | ||
| Notation = <<"no_route_found:rejected:limit_overflow:limit-that-overflowed">>, | ||
| Notation = erlang:list_to_binary( | ||
| payproc_errors:format('PaymentFailure', payproc_errors:from_notation(Notation)) | ||
| ). | ||
|
|
||
| -spec bad_static_type_test(config()) -> _. | ||
| bad_static_type_test(_C) -> | ||
| Bad = {qwe, #payproc_error_GeneralFailure{}}, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зависит от valitydev/damsel#221