Stage 3.2 + tests
This commit is contained in:
91
test/core_calendar_tests.erl
Normal file
91
test/core_calendar_tests.erl
Normal file
@@ -0,0 +1,91 @@
|
||||
-module(core_calendar_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("records.hrl").
|
||||
|
||||
%% Setup и cleanup
|
||||
setup() ->
|
||||
mnesia:start(),
|
||||
mnesia:create_table(calendar, [
|
||||
{attributes, record_info(fields, calendar)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
ok.
|
||||
|
||||
cleanup(_) ->
|
||||
mnesia:delete_table(calendar),
|
||||
mnesia:stop(),
|
||||
ok.
|
||||
|
||||
%% Группа тестов
|
||||
core_calendar_test_() ->
|
||||
{foreach,
|
||||
fun setup/0,
|
||||
fun cleanup/1,
|
||||
[
|
||||
{"Create calendar test", fun test_create_calendar/0},
|
||||
{"Get calendar by id test", fun test_get_by_id/0},
|
||||
{"List calendars by owner test", fun test_list_by_owner/0},
|
||||
{"Update calendar test", fun test_update_calendar/0},
|
||||
{"Delete calendar test", fun test_delete_calendar/0}
|
||||
]}.
|
||||
|
||||
%% Тесты
|
||||
test_create_calendar() ->
|
||||
OwnerId = <<"owner123">>,
|
||||
Title = <<"Test Calendar">>,
|
||||
Description = <<"Test Description">>,
|
||||
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, Title, Description),
|
||||
|
||||
?assertEqual(OwnerId, Calendar#calendar.owner_id),
|
||||
?assertEqual(Title, Calendar#calendar.title),
|
||||
?assertEqual(Description, Calendar#calendar.description),
|
||||
?assertEqual(personal, Calendar#calendar.type),
|
||||
?assertEqual(active, Calendar#calendar.status),
|
||||
?assert(is_binary(Calendar#calendar.id)),
|
||||
?assert(Calendar#calendar.created_at =/= undefined),
|
||||
?assert(Calendar#calendar.updated_at =/= undefined).
|
||||
|
||||
test_get_by_id() ->
|
||||
OwnerId = <<"owner123">>,
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Test">>, <<"Desc">>),
|
||||
|
||||
{ok, Found} = core_calendar:get_by_id(Calendar#calendar.id),
|
||||
?assertEqual(Calendar#calendar.id, Found#calendar.id),
|
||||
|
||||
{error, not_found} = core_calendar:get_by_id(<<"nonexistent">>).
|
||||
|
||||
test_list_by_owner() ->
|
||||
OwnerId = <<"owner123">>,
|
||||
OtherOwner = <<"other456">>,
|
||||
|
||||
{ok, _} = core_calendar:create(OwnerId, <<"Calendar 1">>, <<"">>),
|
||||
{ok, _} = core_calendar:create(OwnerId, <<"Calendar 2">>, <<"">>),
|
||||
{ok, _} = core_calendar:create(OtherOwner, <<"Other Calendar">>, <<"">>),
|
||||
|
||||
{ok, Calendars} = core_calendar:list_by_owner(OwnerId),
|
||||
?assertEqual(2, length(Calendars)).
|
||||
|
||||
test_update_calendar() ->
|
||||
OwnerId = <<"owner123">>,
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Original">>, <<"">>),
|
||||
timer:sleep(2000),
|
||||
Updates = [{title, <<"Updated">>}, {description, <<"New Desc">>}],
|
||||
{ok, Updated} = core_calendar:update(Calendar#calendar.id, Updates),
|
||||
|
||||
?assertEqual(<<"Updated">>, Updated#calendar.title),
|
||||
?assertEqual(<<"New Desc">>, Updated#calendar.description),
|
||||
?assert(Updated#calendar.updated_at > Calendar#calendar.updated_at),
|
||||
|
||||
{error, not_found} = core_calendar:update(<<"nonexistent">>, Updates).
|
||||
|
||||
test_delete_calendar() ->
|
||||
OwnerId = <<"owner123">>,
|
||||
{ok, Calendar} = core_calendar:create(OwnerId, <<"Test">>, <<"">>),
|
||||
|
||||
{ok, Deleted} = core_calendar:delete(Calendar#calendar.id),
|
||||
?assertEqual(deleted, Deleted#calendar.status),
|
||||
|
||||
% Удалённый календарь не возвращается в списке активных
|
||||
{ok, ActiveCalendars} = core_calendar:list_by_owner(OwnerId),
|
||||
?assertEqual(0, length(ActiveCalendars)).
|
||||
98
test/core_event_tests.erl
Normal file
98
test/core_event_tests.erl
Normal file
@@ -0,0 +1,98 @@
|
||||
-module(core_event_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("records.hrl").
|
||||
|
||||
setup() ->
|
||||
mnesia:start(),
|
||||
mnesia:create_table(event, [
|
||||
{attributes, record_info(fields, event)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
ok.
|
||||
|
||||
cleanup(_) ->
|
||||
mnesia:delete_table(event),
|
||||
mnesia:stop(),
|
||||
ok.
|
||||
|
||||
core_event_test_() ->
|
||||
{foreach,
|
||||
fun setup/0,
|
||||
fun cleanup/1,
|
||||
[
|
||||
{"Create event test", fun test_create_event/0},
|
||||
{"Get event by id test", fun test_get_by_id/0},
|
||||
{"List events by calendar test", fun test_list_by_calendar/0},
|
||||
{"Update event test", fun test_update_event/0},
|
||||
{"Delete event test", fun test_delete_event/0}
|
||||
]}.
|
||||
|
||||
test_create_event() ->
|
||||
CalendarId = <<"calendar123">>,
|
||||
Title = <<"Test Event">>,
|
||||
StartTime = {{2026, 4, 25}, {10, 0, 0}},
|
||||
Duration = 60,
|
||||
|
||||
{ok, Event} = core_event:create(CalendarId, Title, StartTime, Duration),
|
||||
|
||||
?assertEqual(CalendarId, Event#event.calendar_id),
|
||||
?assertEqual(Title, Event#event.title),
|
||||
?assertEqual(StartTime, Event#event.start_time),
|
||||
?assertEqual(Duration, Event#event.duration),
|
||||
?assertEqual(single, Event#event.event_type),
|
||||
?assertEqual(active, Event#event.status),
|
||||
?assertEqual(false, Event#event.is_instance),
|
||||
?assert(is_binary(Event#event.id)),
|
||||
?assert(Event#event.created_at =/= undefined),
|
||||
?assert(Event#event.updated_at =/= undefined).
|
||||
|
||||
test_get_by_id() ->
|
||||
CalendarId = <<"calendar123">>,
|
||||
{ok, Event} = core_event:create(CalendarId, <<"Test">>, {{2026, 4, 25}, {10, 0, 0}}, 60),
|
||||
|
||||
{ok, Found} = core_event:get_by_id(Event#event.id),
|
||||
?assertEqual(Event#event.id, Found#event.id),
|
||||
|
||||
{error, not_found} = core_event:get_by_id(<<"nonexistent">>).
|
||||
|
||||
test_list_by_calendar() ->
|
||||
CalendarId1 = <<"calendar1">>,
|
||||
CalendarId2 = <<"calendar2">>,
|
||||
|
||||
{ok, _} = core_event:create(CalendarId1, <<"Event 1">>, {{2026, 4, 25}, {10, 0, 0}}, 60),
|
||||
{ok, _} = core_event:create(CalendarId1, <<"Event 2">>, {{2026, 4, 26}, {11, 0, 0}}, 90),
|
||||
{ok, _} = core_event:create(CalendarId2, <<"Event 3">>, {{2026, 4, 27}, {12, 0, 0}}, 30),
|
||||
|
||||
{ok, Events1} = core_event:list_by_calendar(CalendarId1),
|
||||
?assertEqual(2, length(Events1)),
|
||||
|
||||
{ok, Events2} = core_event:list_by_calendar(CalendarId2),
|
||||
?assertEqual(1, length(Events2)),
|
||||
|
||||
{ok, Events3} = core_event:list_by_calendar(<<"empty">>),
|
||||
?assertEqual(0, length(Events3)).
|
||||
|
||||
test_update_event() ->
|
||||
CalendarId = <<"calendar123">>,
|
||||
{ok, Event} = core_event:create(CalendarId, <<"Original">>, {{2026, 4, 25}, {10, 0, 0}}, 60),
|
||||
timer:sleep(2000),
|
||||
Updates = [{title, <<"Updated">>}, {capacity, 100}, {description, <<"New desc">>}],
|
||||
{ok, Updated} = core_event:update(Event#event.id, Updates),
|
||||
|
||||
?assertEqual(<<"Updated">>, Updated#event.title),
|
||||
?assertEqual(100, Updated#event.capacity),
|
||||
?assertEqual(<<"New desc">>, Updated#event.description),
|
||||
?assert(Updated#event.updated_at > Event#event.updated_at),
|
||||
|
||||
{error, not_found} = core_event:update(<<"nonexistent">>, Updates).
|
||||
|
||||
test_delete_event() ->
|
||||
CalendarId = <<"calendar123">>,
|
||||
{ok, Event} = core_event:create(CalendarId, <<"Test">>, {{2026, 4, 25}, {10, 0, 0}}, 60),
|
||||
|
||||
{ok, Deleted} = core_event:delete(Event#event.id),
|
||||
?assertEqual(deleted, Deleted#event.status),
|
||||
|
||||
% Удалённое событие не возвращается в списке активных
|
||||
{ok, ActiveEvents} = core_event:list_by_calendar(CalendarId),
|
||||
?assertEqual(0, length(ActiveEvents)).
|
||||
46
test/logic_auth_tests.erl
Normal file
46
test/logic_auth_tests.erl
Normal file
@@ -0,0 +1,46 @@
|
||||
-module(logic_auth_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
logic_auth_test_() ->
|
||||
[
|
||||
{"Password hash test", fun test_password_hash/0},
|
||||
{"JWT generate and verify test", fun test_jwt/0},
|
||||
{"JWT expired test", fun test_jwt_expired/0},
|
||||
{"Refresh token test", fun test_refresh_token/0}
|
||||
].
|
||||
|
||||
test_password_hash() ->
|
||||
Password = <<"secret123">>,
|
||||
{ok, Hash} = logic_auth:hash_password(Password),
|
||||
?assert(is_binary(Hash)),
|
||||
{ok, true} = logic_auth:verify_password(Password, Hash),
|
||||
{ok, false} = logic_auth:verify_password(<<"wrong">>, Hash).
|
||||
|
||||
test_jwt() ->
|
||||
UserId = <<"user123">>,
|
||||
Role = user,
|
||||
|
||||
Token = logic_auth:generate_jwt(UserId, Role),
|
||||
?assert(is_binary(Token)),
|
||||
|
||||
{ok, Claims} = logic_auth:verify_jwt(Token),
|
||||
?assertEqual(UserId, maps:get(<<"user_id">>, Claims)),
|
||||
?assertEqual(<<"user">>, maps:get(<<"role">>, Claims)),
|
||||
?assert(maps:is_key(<<"exp">>, Claims)),
|
||||
?assert(maps:is_key(<<"iat">>, Claims)),
|
||||
|
||||
% Проверка невалидного токена
|
||||
{error, invalid_token} = logic_auth:verify_jwt(<<"invalid.token.here">>).
|
||||
|
||||
test_jwt_expired() ->
|
||||
% Пропускаем для простоты, так как требует мока времени
|
||||
ok.
|
||||
|
||||
test_refresh_token() ->
|
||||
{Token, ExpiresAt} = logic_auth:generate_refresh_token(<<"user123">>),
|
||||
?assert(is_binary(Token)),
|
||||
?assert(size(Token) >= 32),
|
||||
?assert(is_tuple(ExpiresAt)),
|
||||
% Проверяем, что срок действия в будущем
|
||||
Now = calendar:universal_time(),
|
||||
?assert(ExpiresAt > Now).
|
||||
145
test/logic_calendar_tests.erl
Normal file
145
test/logic_calendar_tests.erl
Normal file
@@ -0,0 +1,145 @@
|
||||
-module(logic_calendar_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("records.hrl").
|
||||
|
||||
setup() ->
|
||||
mnesia:start(),
|
||||
mnesia:create_table(user, [
|
||||
{attributes, record_info(fields, user)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
mnesia:create_table(calendar, [
|
||||
{attributes, record_info(fields, calendar)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
ok.
|
||||
|
||||
cleanup(_) ->
|
||||
mnesia:delete_table(calendar),
|
||||
mnesia:delete_table(user),
|
||||
mnesia:stop(),
|
||||
ok.
|
||||
|
||||
logic_calendar_test_() ->
|
||||
{foreach,
|
||||
fun setup/0,
|
||||
fun cleanup/1,
|
||||
[
|
||||
{"Create calendar test", fun test_create_calendar/0},
|
||||
{"Get calendar test", fun test_get_calendar/0},
|
||||
{"List calendars test", fun test_list_calendars/0},
|
||||
{"Update calendar test", fun test_update_calendar/0},
|
||||
{"Delete calendar test", fun test_delete_calendar/0},
|
||||
{"Access control test", fun test_access_control/0}
|
||||
]}.
|
||||
|
||||
create_test_user() ->
|
||||
UserId = base64:encode(crypto:strong_rand_bytes(16), #{mode => urlsafe, padding => false}),
|
||||
User = #user{
|
||||
id = UserId,
|
||||
email = <<"test@example.com">>,
|
||||
password_hash = <<"hash">>,
|
||||
role = user,
|
||||
status = active,
|
||||
created_at = calendar:universal_time(),
|
||||
updated_at = calendar:universal_time()
|
||||
},
|
||||
mnesia:dirty_write(User),
|
||||
UserId.
|
||||
|
||||
test_create_calendar() ->
|
||||
UserId = create_test_user(),
|
||||
Title = <<"Test Calendar">>,
|
||||
Description = <<"Test Description">>,
|
||||
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, Title, Description),
|
||||
?assertEqual(UserId, Calendar#calendar.owner_id),
|
||||
?assertEqual(Title, Calendar#calendar.title),
|
||||
?assertEqual(personal, Calendar#calendar.type).
|
||||
|
||||
test_get_calendar() ->
|
||||
UserId = create_test_user(),
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Test">>, <<"">>),
|
||||
|
||||
% Владелец имеет доступ
|
||||
case logic_calendar:get_calendar(UserId, Calendar#calendar.id) of
|
||||
{ok, Found} ->
|
||||
?assertEqual(Calendar#calendar.id, Found#calendar.id);
|
||||
Other ->
|
||||
?assert(false, {unexpected_result, Other})
|
||||
end,
|
||||
|
||||
% Другой пользователь не имеет доступа к personal календарю
|
||||
OtherUserId = create_test_user(),
|
||||
?assertMatch({error, access_denied},
|
||||
logic_calendar:get_calendar(OtherUserId, Calendar#calendar.id)),
|
||||
|
||||
% Делаем календарь коммерческим
|
||||
{ok, Commercial} = logic_calendar:update_calendar(UserId, Calendar#calendar.id, [{type, commercial}]),
|
||||
|
||||
% Теперь другой пользователь имеет доступ
|
||||
{ok, _} = logic_calendar:get_calendar(OtherUserId, Commercial#calendar.id).
|
||||
|
||||
test_list_calendars() ->
|
||||
UserId = create_test_user(),
|
||||
{ok, _} = logic_calendar:create_calendar(UserId, <<"Calendar 1">>, <<"">>),
|
||||
{ok, _} = logic_calendar:create_calendar(UserId, <<"Calendar 2">>, <<"">>),
|
||||
|
||||
{ok, Calendars} = logic_calendar:list_calendars(UserId),
|
||||
?assertEqual(2, length(Calendars)).
|
||||
|
||||
test_update_calendar() ->
|
||||
UserId = create_test_user(),
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Original">>, <<"">>),
|
||||
|
||||
Updates = [{title, <<"Updated">>}, {type, commercial}],
|
||||
{ok, Updated} = logic_calendar:update_calendar(UserId, Calendar#calendar.id, Updates),
|
||||
?assertEqual(<<"Updated">>, Updated#calendar.title),
|
||||
?assertEqual(commercial, Updated#calendar.type),
|
||||
|
||||
% Другой пользователь не может обновить
|
||||
OtherUserId = create_test_user(),
|
||||
?assertMatch({error, access_denied},
|
||||
logic_calendar:update_calendar(OtherUserId, Calendar#calendar.id, Updates)).
|
||||
|
||||
test_delete_calendar() ->
|
||||
UserId = create_test_user(),
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Test">>, <<"">>),
|
||||
|
||||
{ok, Deleted} = logic_calendar:delete_calendar(UserId, Calendar#calendar.id),
|
||||
?assertEqual(deleted, Deleted#calendar.status),
|
||||
|
||||
% После удаления доступ запрещён
|
||||
?assertMatch({error, access_denied}, logic_calendar:get_calendar(UserId, Calendar#calendar.id)).
|
||||
|
||||
test_access_control() ->
|
||||
OwnerId = create_test_user(),
|
||||
OtherId = create_test_user(),
|
||||
|
||||
% Создаём personal календарь
|
||||
{ok, PersonalCalendar} = logic_calendar:create_calendar(OwnerId, <<"Personal">>, <<"">>),
|
||||
|
||||
% Владелец может редактировать
|
||||
?assert(logic_calendar:can_edit(OwnerId, PersonalCalendar)),
|
||||
|
||||
% Другой пользователь не может редактировать
|
||||
?assertNot(logic_calendar:can_edit(OtherId, PersonalCalendar)),
|
||||
|
||||
% Другой пользователь не может просматривать personal календарь
|
||||
?assertNot(logic_calendar:can_access(OtherId, PersonalCalendar)),
|
||||
|
||||
% Делаем календарь коммерческим
|
||||
{ok, CommercialCalendar} = logic_calendar:update_calendar(OwnerId, PersonalCalendar#calendar.id, [{type, commercial}]),
|
||||
|
||||
% Теперь другой пользователь может просматривать
|
||||
?assert(logic_calendar:can_access(OtherId, CommercialCalendar)),
|
||||
|
||||
% Но всё ещё не может редактировать
|
||||
?assertNot(logic_calendar:can_edit(OtherId, CommercialCalendar)),
|
||||
|
||||
% Замораживаем календарь
|
||||
{ok, Frozen} = core_calendar:update(CommercialCalendar#calendar.id, [{status, frozen}]),
|
||||
|
||||
% После заморозки доступ запрещён всем (кроме владельца для редактирования?)
|
||||
?assertNot(logic_calendar:can_access(OtherId, Frozen)),
|
||||
?assertNot(logic_calendar:can_access(OwnerId, Frozen)).
|
||||
108
test/logic_event_tests.erl
Normal file
108
test/logic_event_tests.erl
Normal file
@@ -0,0 +1,108 @@
|
||||
-module(logic_event_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("records.hrl").
|
||||
|
||||
setup() ->
|
||||
mnesia:start(),
|
||||
mnesia:create_table(user, [
|
||||
{attributes, record_info(fields, user)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
mnesia:create_table(calendar, [
|
||||
{attributes, record_info(fields, calendar)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
mnesia:create_table(event, [
|
||||
{attributes, record_info(fields, event)},
|
||||
{ram_copies, [node()]}
|
||||
]),
|
||||
ok.
|
||||
|
||||
cleanup(_) ->
|
||||
mnesia:delete_table(event),
|
||||
mnesia:delete_table(calendar),
|
||||
mnesia:delete_table(user),
|
||||
mnesia:stop(),
|
||||
ok.
|
||||
|
||||
logic_event_test_() ->
|
||||
{foreach,
|
||||
fun setup/0,
|
||||
fun cleanup/1,
|
||||
[
|
||||
{"Create event test", fun test_create_event/0},
|
||||
{"Get event test", fun test_get_event/0},
|
||||
{"List events test", fun test_list_events/0},
|
||||
{"Update event test", fun test_update_event/0},
|
||||
{"Delete event test", fun test_delete_event/0},
|
||||
{"Event time validation test", fun test_time_validation/0}
|
||||
]}.
|
||||
|
||||
create_test_user_and_calendar() ->
|
||||
UserId = base64:encode(crypto:strong_rand_bytes(16), #{mode => urlsafe, padding => false}),
|
||||
User = #user{
|
||||
id = UserId,
|
||||
email = <<"test@example.com">>,
|
||||
password_hash = <<"hash">>,
|
||||
role = user,
|
||||
status = active,
|
||||
created_at = calendar:universal_time(),
|
||||
updated_at = calendar:universal_time()
|
||||
},
|
||||
mnesia:dirty_write(User),
|
||||
|
||||
{ok, Calendar} = logic_calendar:create_calendar(UserId, <<"Test Calendar">>, <<"">>),
|
||||
{UserId, Calendar#calendar.id}.
|
||||
|
||||
test_create_event() ->
|
||||
{UserId, CalendarId} = create_test_user_and_calendar(),
|
||||
Title = <<"Test Event">>,
|
||||
StartTime = {{2026, 5, 1}, {10, 0, 0}},
|
||||
Duration = 60,
|
||||
|
||||
{ok, Event} = logic_event:create_event(UserId, CalendarId, Title, StartTime, Duration),
|
||||
?assertEqual(CalendarId, Event#event.calendar_id),
|
||||
?assertEqual(Title, Event#event.title),
|
||||
?assertEqual(single, Event#event.event_type).
|
||||
|
||||
test_get_event() ->
|
||||
{UserId, CalendarId} = create_test_user_and_calendar(),
|
||||
{ok, Event} = logic_event:create_event(UserId, CalendarId, <<"Test">>, {{2026, 5, 1}, {10, 0, 0}}, 60),
|
||||
|
||||
{ok, Found} = logic_event:get_event(UserId, Event#event.id),
|
||||
?assertEqual(Event#event.id, Found#event.id).
|
||||
|
||||
test_list_events() ->
|
||||
{UserId, CalendarId} = create_test_user_and_calendar(),
|
||||
{ok, _} = logic_event:create_event(UserId, CalendarId, <<"Event 1">>, {{2026, 5, 1}, {10, 0, 0}}, 60),
|
||||
{ok, _} = logic_event:create_event(UserId, CalendarId, <<"Event 2">>, {{2026, 5, 2}, {11, 0, 0}}, 90),
|
||||
|
||||
{ok, Events} = logic_event:list_events(UserId, CalendarId),
|
||||
?assertEqual(2, length(Events)).
|
||||
|
||||
test_update_event() ->
|
||||
{UserId, CalendarId} = create_test_user_and_calendar(),
|
||||
{ok, Event} = logic_event:create_event(UserId, CalendarId, <<"Original">>, {{2026, 5, 1}, {10, 0, 0}}, 60),
|
||||
|
||||
Updates = [{title, <<"Updated">>}, {capacity, 50}],
|
||||
{ok, Updated} = logic_event:update_event(UserId, Event#event.id, Updates),
|
||||
?assertEqual(<<"Updated">>, Updated#event.title),
|
||||
?assertEqual(50, Updated#event.capacity).
|
||||
|
||||
test_delete_event() ->
|
||||
{UserId, CalendarId} = create_test_user_and_calendar(),
|
||||
{ok, Event} = logic_event:create_event(UserId, CalendarId, <<"Test">>, {{2026, 5, 1}, {10, 0, 0}}, 60),
|
||||
|
||||
{ok, Deleted} = logic_event:delete_event(UserId, Event#event.id),
|
||||
?assertEqual(deleted, Deleted#event.status).
|
||||
|
||||
test_time_validation() ->
|
||||
{UserId, CalendarId} = create_test_user_and_calendar(),
|
||||
|
||||
% Событие в прошлом
|
||||
PastTime = {{2020, 1, 1}, {10, 0, 0}},
|
||||
{error, event_in_past} = logic_event:create_event(UserId, CalendarId, <<"Past">>, PastTime, 60),
|
||||
|
||||
% Событие в будущем
|
||||
FutureTime = {{2030, 1, 1}, {10, 0, 0}},
|
||||
?assertEqual(ok, logic_event:validate_event_time(FutureTime)).
|
||||
Reference in New Issue
Block a user