Добавить авто-регистрацию тикетов (hash/dedupe/500/WS). Refs EventHub/EventHubBack#35
CI / test (push) Successful in 21m45s
CI / deploy-ift (push) Successful in 6m8s
CI / e2e-ift (push) Failing after 6m13s
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

This commit is contained in:
2026-07-17 00:44:09 +03:00
parent 0a52712258
commit a696d25486
12 changed files with 590 additions and 59 deletions
+20 -1
View File
@@ -42,6 +42,8 @@ logic_ticket_test_() ->
{foreach, fun setup/0, fun cleanup/1, [
{"Report error creates ticket", fun test_report_error/0},
{"Report duplicate error increments count", fun test_report_duplicate/0},
{"Report after close creates new ticket", fun test_report_after_close/0},
{"Frontend source set on ticket", fun test_report_frontend_source/0},
{"List tickets as admin", fun test_list_tickets/0},
{"List tickets as non-admin returns error", fun test_list_tickets_forbidden/0},
{"Update status as admin", fun test_update_status/0},
@@ -55,12 +57,18 @@ logic_ticket_test_() ->
report(ErrorMsg) ->
logic_ticket:report_error(ErrorMsg, <<"stack">>, #{<<"reporter_id">> => <<"user1">>}).
report(Source, ErrorMsg) ->
logic_ticket:report_error(Source, ErrorMsg, <<"stack">>, #{<<"reporter_id">> => <<"user1">>}).
%% --- Тесты ---
test_report_error() ->
{ok, Ticket} = report(<<"Error1">>),
?assertEqual(<<"Error1">>, Ticket#ticket.error_message),
?assertEqual(1, Ticket#ticket.count).
?assertEqual(1, Ticket#ticket.count),
?assertEqual(<<"backend">>, Ticket#ticket.source),
?assert(is_binary(Ticket#ticket.error_hash)),
?assert(byte_size(Ticket#ticket.error_hash) > 0).
test_report_duplicate() ->
{ok, T1} = report(<<"Dup">>),
@@ -70,6 +78,17 @@ test_report_duplicate() ->
% Проверяем, что это тот же тикет, а не новый
?assertEqual(T1#ticket.id, T2#ticket.id).
test_report_after_close() ->
{ok, T1} = report(<<"ClosedThenAgain">>),
{ok, _} = logic_ticket:close_ticket(<<"admin1">>, T1#ticket.id),
{ok, T2} = report(<<"ClosedThenAgain">>),
?assertEqual(1, T2#ticket.count),
?assertNotEqual(T1#ticket.id, T2#ticket.id).
test_report_frontend_source() ->
{ok, Ticket} = report(frontend, <<"FE crash">>),
?assertEqual(<<"frontend">>, Ticket#ticket.source).
test_list_tickets() ->
{ok, _} = report(<<"E1">>),
Tickets = logic_ticket:list_tickets(<<"admin1">>),