mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
ci: add tests (#1141)
This commit is contained in:
1 parent
ad99de22bc
commit
545814abc1
152 files changed
+287
-532
No files matched your search
@@ -162,9 +162,7 @@ sanitize_text(Bin) when is_binary(Bin) ->
|
||||
safe_codepoints_to_binary(Codepoints, Bin);
|
||||
_ ->
|
||||
Bin
|
||||
end;
|
||||
sanitize_text(Other) ->
|
||||
Other.
|
||||
end.
|
||||
|
||||
-spec safe_codepoints_to_binary([integer()], binary()) -> binary().
|
||||
safe_codepoints_to_binary(Codepoints, Fallback) ->
|
||||
|
||||
@@ -35,8 +35,7 @@ render_bounded_context(Content, ContextJson) when
|
||||
byte_size(ContextJson) =< ?MAX_CONTEXT_JSON_BYTES
|
||||
->
|
||||
try push_markdown_plaintext_nif:render_push_preview_nif(Content, ContextJson) of
|
||||
Preview when is_binary(Preview) -> Preview;
|
||||
_ -> strip_to_safe(Content)
|
||||
Preview when is_binary(Preview) -> Preview
|
||||
catch
|
||||
_:_ -> strip_to_safe(Content)
|
||||
end;
|
||||
|
||||
@@ -20,24 +20,24 @@ init() ->
|
||||
|
||||
-spec available() -> boolean().
|
||||
available() ->
|
||||
false.
|
||||
erlang:nif_error(nif_not_loaded).
|
||||
|
||||
-spec render_push_preview_nif(binary(), binary()) -> binary().
|
||||
render_push_preview_nif(_Content, _ContextJson) ->
|
||||
erlang:nif_error(nif_not_loaded).
|
||||
|
||||
-spec nif_path() -> file:filename().
|
||||
-spec nif_path() -> file:filename_all().
|
||||
nif_path() ->
|
||||
filename:join(priv_dir(), ?NIF_NAME).
|
||||
|
||||
-spec priv_dir() -> file:filename().
|
||||
-spec priv_dir() -> file:filename_all().
|
||||
priv_dir() ->
|
||||
case code:priv_dir(fluxer_gateway) of
|
||||
{error, _Reason} -> priv_dir_from_beam();
|
||||
Dir -> Dir
|
||||
end.
|
||||
|
||||
-spec priv_dir_from_beam() -> file:filename().
|
||||
-spec priv_dir_from_beam() -> file:filename_all().
|
||||
priv_dir_from_beam() ->
|
||||
case code:which(?MODULE) of
|
||||
Beam when is_list(Beam) ->
|
||||
|
||||
@@ -167,9 +167,7 @@ user_nickname(UserId0, UserNicknames) when is_map(UserNicknames) ->
|
||||
case user_id_binary(UserId0) of
|
||||
Id when is_binary(Id) -> maps:get(Id, UserNicknames, undefined);
|
||||
undefined -> undefined
|
||||
end;
|
||||
user_nickname(_UserId0, _UserNicknames) ->
|
||||
undefined.
|
||||
end.
|
||||
|
||||
-spec user_id_binary(term()) -> binary() | undefined.
|
||||
user_id_binary(UserId) when is_integer(UserId), UserId > 0 ->
|
||||
@@ -266,9 +264,7 @@ channel_names_from_guild_data(ChannelIds, GuildData) when is_map(GuildData) ->
|
||||
fun(ChannelId, Acc) -> put_index_channel_name(ChannelId, ChannelIndex, Acc) end,
|
||||
#{},
|
||||
ChannelIds
|
||||
);
|
||||
channel_names_from_guild_data(_ChannelIds, _GuildData) ->
|
||||
#{}.
|
||||
).
|
||||
|
||||
-spec put_index_channel_name(integer(), map(), map()) -> map().
|
||||
put_index_channel_name(ChannelId, ChannelIndex, Acc) ->
|
||||
|
||||
Reference in new issue
Block a user