Tag Mock
-tests as "mocked" and run them seperately
This commit is contained in:
parent
9aaf5c9332
commit
64e233ca20
49 changed files with 58 additions and 7 deletions
|
@ -110,4 +110,5 @@ pipeline:
|
|||
- mix ecto.create
|
||||
- mix ecto.migrate
|
||||
- mkdir -p test/tmp
|
||||
- mix test --preload-modules --exclude erratic --exclude federated
|
||||
- mix test --preload-modules --exclude erratic --exclude federated --exclude mocked
|
||||
- mix test --preload-modules --only mocked
|
||||
|
|
|
@ -117,6 +117,8 @@ def refetch_object(%Object{data: %{"id" => id}} = object) do
|
|||
# Note: will create a Create activity, which we need internally at the moment.
|
||||
def fetch_object_from_id(id, options \\ []) do
|
||||
with %URI{} = uri <- URI.parse(id),
|
||||
# let's check the URI is even vaguely valid first
|
||||
{:scheme, true} <- {:scheme, uri.scheme == "http" or uri.scheme == "https"},
|
||||
# If we have instance restrictions, apply them here to prevent fetching from unwanted instances
|
||||
{:ok, nil} <- Pleroma.Web.ActivityPub.MRF.SimplePolicy.check_reject(uri),
|
||||
{:ok, _} <- Pleroma.Web.ActivityPub.MRF.SimplePolicy.check_accept(uri),
|
||||
|
@ -135,6 +137,9 @@ def fetch_object_from_id(id, options \\ []) do
|
|||
{:allowed_depth, false} ->
|
||||
{:error, "Max thread distance exceeded."}
|
||||
|
||||
{:scheme, false} ->
|
||||
{:error, "URI Scheme Invalid"}
|
||||
|
||||
{:containment, _} ->
|
||||
{:error, "Object containment failed."}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule Mix.Tasks.Pleroma.Ecto.MigrateTest do
|
|||
|
||||
test "ecto.migrate info message" do
|
||||
level = Logger.level()
|
||||
Logger.configure(level: :warn)
|
||||
Logger.configure(level: :warning)
|
||||
|
||||
assert capture_log(fn ->
|
||||
Mix.Tasks.Pleroma.Ecto.Migrate.run()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Mix.Tasks.Pleroma.UploadsTest do
|
||||
alias Pleroma.Upload
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
|
||||
use Pleroma.DataCase, async: false
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
@moduletag :mocked
|
||||
|
||||
import ExUnit.CaptureIO
|
||||
import Mock
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Activity.Ir.TopicsTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Activity.Ir.Topics
|
||||
|
|
|
@ -3,7 +3,8 @@ defmodule Pleroma.Akkoma.Translators.ArgosTranslateTest do
|
|||
|
||||
import Mock
|
||||
|
||||
use Pleroma.DataCase, async: true
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
setup do
|
||||
clear_config([:argos_translate, :command_argos_translate], "argos-translate_test")
|
||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
|
|||
use Pleroma.DataCase, async: false
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
@moduletag :mocked
|
||||
import Mock
|
||||
|
||||
alias Pleroma.ApplicationRequirements
|
||||
|
|
|
@ -428,13 +428,13 @@ test "complex keyword with nested mixed childs" do
|
|||
|
||||
test "common keyword" do
|
||||
assert ConfigDB.to_elixir_types([
|
||||
%{"tuple" => [":level", ":warn"]},
|
||||
%{"tuple" => [":level", ":warning"]},
|
||||
%{"tuple" => [":meta", [":all"]]},
|
||||
%{"tuple" => [":path", ""]},
|
||||
%{"tuple" => [":val", nil]},
|
||||
%{"tuple" => [":webhook_url", "https://hooks.slack.com/services/YOUR-KEY-HERE"]}
|
||||
]) == [
|
||||
level: :warn,
|
||||
level: :warning,
|
||||
meta: [:all],
|
||||
path: "",
|
||||
val: nil,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.NotificationTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Pleroma.Factory
|
||||
import Mock
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Object.FetcherTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Instances
|
||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Search.ElasticsearchTest do
|
|||
require Pleroma.Constants
|
||||
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Search.MeilisearchTest do
|
|||
require Pleroma.Constants
|
||||
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.SignatureTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
defmodule Pleroma.Upload.Filter.MogrifunTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
|
||||
alias Pleroma.Upload
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Upload.Filter.MogrifyTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
import Mock
|
||||
|
||||
alias Pleroma.Upload.Filter
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Uploaders.S3Test do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Uploaders.S3
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.User.BackupTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.UserRelationshipTest do
|
|||
alias Pleroma.UserRelationship
|
||||
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
alias Pleroma.Activity
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicyTest do
|
||||
use ExUnit.Case, async: false
|
||||
@moduletag :mocked
|
||||
use Pleroma.Tests.Helpers
|
||||
|
||||
alias Pleroma.HTTP
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ActivityPub.RelayTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.User
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Notification
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Repo
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase, async: false
|
||||
|
||||
@moduletag :mocked
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
|
@ -536,7 +536,7 @@ test "returns non-modified object" do
|
|||
test "returns nil when cannot normalize object" do
|
||||
assert capture_log(fn ->
|
||||
refute Transmogrifier.get_obj_helper("test-obj-id")
|
||||
end) =~ "Unsupported URI scheme"
|
||||
end) =~ "URI Scheme Invalid"
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Pleroma.Factory
|
||||
import Mock
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
import Mock
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Web.CommonAPITest do
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Conversation.Participation
|
||||
|
|
|
@ -10,6 +10,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
alias Pleroma.Workers.PublisherWorker
|
||||
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
import Mock
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Endpoint
|
||||
|
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
alias Pleroma.User
|
||||
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserRelationship
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.MediaProxy.InvalidationTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Web.MediaProxy.Invalidation
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Web.OAuth.Token
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Tesla.Mock
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Tesla.Mock
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.PleromaAPI.UserImportControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlugTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
import Mock
|
||||
|
||||
@dir "test/tmp/instance_static"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.Plugs.HTTPSignaturePlugTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
import Pleroma.Factory
|
||||
alias Pleroma.Web.Plugs.HTTPSignaturePlug
|
||||
alias Pleroma.Instances.Instance
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.Plugs.OAuthScopesPlugTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||
|
|
|
@ -12,6 +12,7 @@ defmodule Pleroma.Web.Plugs.PlugHelperTest do
|
|||
import Mock
|
||||
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
|
||||
describe "when plug is skipped, " do
|
||||
setup_with_mocks(
|
||||
|
|
|
@ -15,6 +15,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
import Pleroma.Factory
|
||||
|
||||
setup_all do: clear_config([:static_fe, :enabled], true)
|
||||
setup do: clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
|
||||
setup %{conn: conn} do
|
||||
conn = put_req_header(conn, "accept", "text/html")
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: false
|
||||
@moduletag :mocked
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Workers.ReceiverWorkerTest do
|
||||
use Pleroma.DataCase, async: false
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
@moduletag :mocked
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
|
Loading…
Reference in a new issue