fix(test): ensure calendar_share table in ACL-related eunit suites.
CI / test (push) Failing after 6m13s
CI / deploy-ift (push) Has been skipped
CI / e2e-ift (push) Has been skipped
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

Harden core_calendar_share get/list when table missing. Refs EventHub/EventHubBack#73
This commit is contained in:
2026-08-15 23:48:12 +03:00
parent 331000a464
commit fcb737eb47
8 changed files with 28 additions and 9 deletions
+16 -3
View File
@@ -41,18 +41,31 @@ upsert(CalendarId, UserId, Rights, Mirror) ->
-spec get(CalendarId :: binary(), UserId :: binary()) -> -spec get(CalendarId :: binary(), UserId :: binary()) ->
{ok, #calendar_share{}} | {error, not_found}. {ok, #calendar_share{}} | {error, not_found}.
get(CalendarId, UserId) -> get(CalendarId, UserId) ->
case find_dirty(CalendarId, UserId) of try find_dirty(CalendarId, UserId) of
[Rec] -> {ok, Rec}; [Rec] -> {ok, Rec};
[] -> {error, not_found} [] -> {error, not_found}
catch
exit:{aborted, {no_exists, _}} -> {error, not_found};
error:_ -> {error, not_found}
end. end.
-spec list_by_calendar(CalendarId :: binary()) -> [#calendar_share{}]. -spec list_by_calendar(CalendarId :: binary()) -> [#calendar_share{}].
list_by_calendar(CalendarId) -> list_by_calendar(CalendarId) ->
mnesia:dirty_match_object(#calendar_share{calendar_id = CalendarId, _ = '_'}). try
mnesia:dirty_match_object(#calendar_share{calendar_id = CalendarId, _ = '_'})
catch
exit:{aborted, {no_exists, _}} -> [];
error:_ -> []
end.
-spec list_by_user(UserId :: binary()) -> [#calendar_share{}]. -spec list_by_user(UserId :: binary()) -> [#calendar_share{}].
list_by_user(UserId) -> list_by_user(UserId) ->
mnesia:dirty_match_object(#calendar_share{user_id = UserId, _ = '_'}). try
mnesia:dirty_match_object(#calendar_share{user_id = UserId, _ = '_'})
catch
exit:{aborted, {no_exists, _}} -> [];
error:_ -> []
end.
-spec delete(CalendarId :: binary(), UserId :: binary()) -> ok | {error, not_found | term()}. -spec delete(CalendarId :: binary(), UserId :: binary()) -> ok | {error, not_found | term()}.
delete(CalendarId, UserId) -> delete(CalendarId, UserId) ->
+1 -1
View File
@@ -2,7 +2,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include("records.hrl"). -include("records.hrl").
-define(TABLES, [user, calendar, event, booking, admin, subscription]). -define(TABLES, [user, calendar, event, booking, admin, subscription, calendar_share]).
setup() -> setup() ->
eh_test_support:start_mnesia(), eh_test_support:start_mnesia(),
+1 -1
View File
@@ -3,7 +3,7 @@
-include("records.hrl"). -include("records.hrl").
-define(TABLES, [user, calendar, event, booking, admin, subscription, calendar_specialist, -define(TABLES, [user, calendar, event, booking, admin, subscription, calendar_specialist,
recurrence_exception, notification, push_subscription]). recurrence_exception, notification, push_subscription, calendar_share]).
setup() -> setup() ->
eh_test_support:start_mnesia(), eh_test_support:start_mnesia(),
+6
View File
@@ -21,9 +21,15 @@ setup() ->
{attributes, record_info(fields, calendar_specialist)}, {attributes, record_info(fields, calendar_specialist)},
{ram_copies, [node()]} {ram_copies, [node()]}
]), ]),
mnesia:create_table(calendar_share, [
{attributes, record_info(fields, calendar_share)},
{ram_copies, [node()]},
{index, [calendar_id, user_id]}
]),
ok. ok.
cleanup(_) -> cleanup(_) ->
mnesia:delete_table(calendar_share),
mnesia:delete_table(calendar_specialist), mnesia:delete_table(calendar_specialist),
mnesia:delete_table(subscription), mnesia:delete_table(subscription),
mnesia:delete_table(calendar), mnesia:delete_table(calendar),
+1 -1
View File
@@ -2,7 +2,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include("records.hrl"). -include("records.hrl").
-define(TABLES, [user, calendar, event, recurrence_exception]). -define(TABLES, [user, calendar, event, recurrence_exception, calendar_share]).
setup() -> setup() ->
eh_test_support:start_mnesia(), eh_test_support:start_mnesia(),
+1 -1
View File
@@ -2,7 +2,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include("records.hrl"). -include("records.hrl").
-define(TABLES, [user, calendar, event, calendar_specialist, subscription]). -define(TABLES, [user, calendar, event, calendar_specialist, subscription, calendar_share]).
setup() -> setup() ->
eh_test_support:start_mnesia(), eh_test_support:start_mnesia(),
+1 -1
View File
@@ -2,7 +2,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include("records.hrl"). -include("records.hrl").
-define(TABLES, [user, calendar, calendar_specialist, subscription, event]). -define(TABLES, [user, calendar, calendar_specialist, subscription, event, calendar_share]).
setup() -> setup() ->
eh_test_support:start_mnesia(), eh_test_support:start_mnesia(),
+1 -1
View File
@@ -2,7 +2,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include("records.hrl"). -include("records.hrl").
-define(TABLES, [user, calendar, event, subscription]). -define(TABLES, [user, calendar, event, subscription, calendar_share]).
setup() -> setup() ->
eh_test_support:start_mnesia(), eh_test_support:start_mnesia(),