Stage 3.4

This commit is contained in:
2026-04-20 16:40:44 +03:00
parent 42a047a938
commit b24cbc97f3
25 changed files with 2520 additions and 123 deletions

View File

@@ -56,13 +56,13 @@ create_test_user_and_calendar() ->
},
mnesia:dirty_write(User),
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Test Calendar">>, <<"">>),
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Test Calendar">>, <<"">>, manual),
{UserId, Calendar#calendar.id}.
test_create_recurring_event() ->
{UserId, CalendarId} = create_test_user_and_calendar(),
Title = <<"Weekly Meeting">>,
StartTime = {{2026, 5, 1}, {10, 0, 0}},
StartTime = {{2026, 6, 1}, {10, 0, 0}},
Duration = 60,
RRule = #{<<"freq">> => <<"WEEKLY">>, <<"interval">> => 1},
@@ -75,7 +75,7 @@ test_create_recurring_event() ->
test_create_recurring_invalid() ->
{UserId, CalendarId} = create_test_user_and_calendar(),
Title = <<"Invalid">>,
StartTime = {{2026, 5, 1}, {10, 0, 0}},
StartTime = {{2026, 6, 1}, {10, 0, 0}},
Duration = 60,
InvalidRRule = #{<<"freq">> => <<"YEARLY">>, <<"interval">> => 1},
@@ -85,17 +85,16 @@ test_create_recurring_invalid() ->
test_get_occurrences() ->
{UserId, CalendarId} = create_test_user_and_calendar(),
StartTime = {{2026, 6, 1}, {10, 0, 0}}, % Июнь 2026
StartTime = {{2026, 6, 1}, {10, 0, 0}},
RRule = #{<<"freq">> => <<"WEEKLY">>, <<"interval">> => 1},
{ok, Event} = logic_event:create_recurring_event(
UserId, CalendarId, <<"Weekly">>, StartTime, 60, RRule
),
RangeEnd = {{2026, 6, 29}, {10, 0, 0}}, % Конец июня
RangeEnd = {{2026, 6, 29}, {10, 0, 0}},
{ok, Occurrences} = logic_event:get_occurrences(UserId, Event#event.id, RangeEnd),
% 1, 8, 15, 22, 29 июня = 5 вхождений
?assertEqual(5, length(Occurrences)).
test_cancel_occurrence() ->
@@ -107,7 +106,7 @@ test_cancel_occurrence() ->
UserId, CalendarId, <<"Weekly">>, StartTime, 60, RRule
),
CancelTime = {{2026, 6, 8}, {10, 0, 0}}, % Второе вхождение
CancelTime = {{2026, 6, 8}, {10, 0, 0}},
{ok, cancelled} = logic_event:cancel_occurrence(UserId, Event#event.id, CancelTime).
test_occurrences_with_cancelled() ->
@@ -119,17 +118,14 @@ test_occurrences_with_cancelled() ->
UserId, CalendarId, <<"Weekly">>, StartTime, 60, RRule
),
% Отменяем второе вхождение
CancelTime = {{2026, 6, 8}, {10, 0, 0}},
{ok, cancelled} = logic_event:cancel_occurrence(UserId, Event#event.id, CancelTime),
RangeEnd = {{2026, 6, 29}, {10, 0, 0}},
{ok, Occurrences} = logic_event:get_occurrences(UserId, Event#event.id, RangeEnd),
% 1, 15, 22, 29 июня = 4 вхождения (одно отменено)
?assertEqual(4, length(Occurrences)),
% Проверяем, что отменённого вхождения нет
Starts = [O || {virtual, O} <- Occurrences],
?assertNot(lists:member(CancelTime, Starts)).