fix(test): ensure calendar_share table in ACL-related eunit suites.
Harden core_calendar_share get/list when table missing. Refs EventHub/EventHubBack#73
This commit is contained in:
@@ -41,18 +41,31 @@ upsert(CalendarId, UserId, Rights, Mirror) ->
|
||||
-spec get(CalendarId :: binary(), UserId :: binary()) ->
|
||||
{ok, #calendar_share{}} | {error, not_found}.
|
||||
get(CalendarId, UserId) ->
|
||||
case find_dirty(CalendarId, UserId) of
|
||||
try find_dirty(CalendarId, UserId) of
|
||||
[Rec] -> {ok, Rec};
|
||||
[] -> {error, not_found}
|
||||
catch
|
||||
exit:{aborted, {no_exists, _}} -> {error, not_found};
|
||||
error:_ -> {error, not_found}
|
||||
end.
|
||||
|
||||
-spec list_by_calendar(CalendarId :: binary()) -> [#calendar_share{}].
|
||||
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{}].
|
||||
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()}.
|
||||
delete(CalendarId, UserId) ->
|
||||
|
||||
Reference in New Issue
Block a user