don't use global mocks in setup callbacks

This commit is contained in:
Alexander Strizhakov 2020-05-13 09:20:25 +03:00
parent b962b24e6f
commit 12635bc156
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
3 changed files with 8 additions and 5 deletions

View file

@ -11,6 +11,11 @@ defmodule Pleroma.ActivityTest do
alias Pleroma.ThreadMute alias Pleroma.ThreadMute
import Pleroma.Factory import Pleroma.Factory
setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok
end
test "returns an activity by it's AP id" do test "returns an activity by it's AP id" do
activity = insert(:note_activity) activity = insert(:note_activity)
found_activity = Activity.get_by_ap_id(activity.data["id"]) found_activity = Activity.get_by_ap_id(activity.data["id"])
@ -107,8 +112,6 @@ test "when association is not loaded" do
describe "search" do describe "search" do
setup do setup do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
user = insert(:user) user = insert(:user)
params = %{ params = %{

View file

@ -13,7 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
import Tesla.Mock import Tesla.Mock
import Mock import Mock
setup do setup_all do
mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok
end end

View file

@ -13,8 +13,8 @@ defmodule Pleroma.Web.Push.ImplTest do
import Pleroma.Factory import Pleroma.Factory
setup_all do setup do
Tesla.Mock.mock_global(fn Tesla.Mock.mock(fn
%{method: :post, url: "https://example.com/example/1234"} -> %{method: :post, url: "https://example.com/example/1234"} ->
%Tesla.Env{status: 200} %Tesla.Env{status: 200}