Remove unused functions

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-10-05 15:29:06 +02:00
parent 5d8d2e80a5
commit f4284e1d3a
41 changed files with 114 additions and 714 deletions

View File

@@ -413,12 +413,6 @@ defmodule Mobilizon.ActorsTest do
@update_attrs %{source: "some updated source", type: "some updated type"}
@invalid_attrs %{source: nil, type: nil}
test "list_bots/0 returns all bots" do
bot = insert(:bot)
bot_found_id = Actors.list_bots() |> hd |> Map.get(:id)
assert bot_found_id == bot.id
end
test "get_bot!/1 returns the bot with given id" do
%Bot{id: bot_id} = bot = insert(:bot)
assert bot_id == Actors.get_bot!(bot.id).id

View File

@@ -12,12 +12,6 @@ defmodule Mobilizon.DiscussionsTest do
@update_attrs %{text: "some updated text"}
@invalid_attrs %{text: nil, url: nil}
test "list_comments/0 returns all comments" do
%Comment{id: comment_id} = insert(:comment)
comment_ids = Discussions.list_comments() |> Enum.map(& &1.id)
assert comment_ids == [comment_id]
end
test "get_comment!/1 returns the comment with given id" do
%Comment{id: comment_id} = insert(:comment)
comment_fetched = Discussions.get_comment!(comment_id)

View File

@@ -301,8 +301,8 @@ defmodule Mobilizon.EventsTest do
assert {:ok, %TagRelation{}} =
Events.create_tag_relation(%{tag_id: tag1_id, link_id: tag2_id})
assert Events.are_tags_linked(tag1, tag2)
assert Events.are_tags_linked(tag2, tag1)
assert Events.are_tags_linked?(tag1, tag2)
assert Events.are_tags_linked?(tag2, tag1)
end
test "create_tag_relation/1 with invalid data returns error changeset", %{
@@ -312,7 +312,7 @@ defmodule Mobilizon.EventsTest do
assert {:error, %Ecto.Changeset{}} =
Events.create_tag_relation(%{tag_id: nil, link_id: nil})
refute Events.are_tags_linked(tag1, tag2)
refute Events.are_tags_linked?(tag1, tag2)
end
test "delete_tag_relation/1 deletes the tag relation" do

View File

@@ -17,12 +17,6 @@ defmodule Mobilizon.MediaTest do
name: "something old"
}
}
@update_attrs %{
file: %{
url: "https://something.tld/media/something_updated",
name: "something new"
}
}
test "get_media!/1 returns the media with given id" do
media = insert(:media)
@@ -36,18 +30,6 @@ defmodule Mobilizon.MediaTest do
assert media.file.name == "something old"
end
test "update_media/2 with valid data updates the media" do
media = insert(:media)
assert {:ok, %Media{} = media} =
Medias.update_media(
media,
Map.put(@update_attrs, :actor_id, insert(:actor).id)
)
assert media.file.name == "something new"
end
test "delete_media/1 deletes the media" do
media = insert(:media)

View File

@@ -128,12 +128,6 @@ defmodule Mobilizon.UsersTest do
setting
end
test "get_setting!/1 returns the setting with given id" do
%User{id: user_id} = insert(:user)
setting = setting_fixture(user_id: user_id)
assert Users.get_setting!(setting.user_id) == setting
end
test "create_setting/1 with valid data creates a setting" do
%User{id: user_id} = insert(:user)
@@ -155,18 +149,5 @@ defmodule Mobilizon.UsersTest do
assert setting.timezone == "Atlantic/Cape_Verde"
assert setting.notification_each_week == false
end
test "delete_setting/1 deletes the setting" do
%User{id: user_id} = insert(:user)
setting = setting_fixture(user_id: user_id)
assert {:ok, %Setting{}} = Users.delete_setting(setting)
assert_raise Ecto.NoResultsError, fn -> Users.get_setting!(setting.user_id) end
end
test "change_setting/1 returns a setting changeset" do
%User{id: user_id} = insert(:user)
setting = setting_fixture(user_id: user_id)
assert %Ecto.Changeset{} = Users.change_setting(setting)
end
end
end

View File

@@ -74,6 +74,21 @@ defmodule Mobilizon.DataCase do
:ok
end
@doc """
POSIX-compliant check if command is available in the system
## Examples
iex> command_available?("git")
true
iex> command_available?("wrongcmd")
false
"""
@spec command_available?(String.t()) :: boolean()
def command_available?(command) do
match?({_output, 0}, System.cmd("sh", ["-c", "command -v #{command}"]))
end
Mox.defmock(Mobilizon.Service.HTTP.ActivityPub.Mock, for: Tesla.Adapter)
Mox.defmock(Mobilizon.Service.HTTP.GeospatialClient.Mock,

View File

@@ -31,7 +31,7 @@ defmodule Mobilizon.Web.WebFingerControllerTest do
test "GET /.well-known/webfinger with local actor", %{conn: conn} do
%Actor{preferred_username: username} = actor = insert(:actor)
conn = get(conn, "/.well-known/webfinger?resource=acct:#{username}@mobilizon.test")
assert json_response(conn, 200) == WebFinger.represent_actor(actor)
assert json_response(conn, 200) == WebFinger.represent_actor(actor, "JSON")
end
test "GET /.well-known/webfinger with non existent actor", %{conn: conn} do

View File

@@ -8,9 +8,15 @@ defmodule Mobilizon.Web.Upload.Filter.ExiftoolTest do
alias Mobilizon.Web.Upload
alias Mobilizon.Web.Upload.Filter
test "apply exiftool filter" do
assert Mobilizon.Utils.command_available?("exiftool")
setup do
if command_available?("exiftool") do
{:ok, skip: true}
else
:ok
end
end
test "apply exiftool filter" do
File.cp!(
"test/fixtures/DSCN0010.jpg",
"test/fixtures/DSCN0010_tmp.jpg"