From 12635bc15626dd7d2d4a02b9c8d763687a0d34ce Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Wed, 13 May 2020 09:20:25 +0300 Subject: [PATCH] don't use global mocks in setup callbacks --- test/activity_test.exs | 7 +++++-- .../mastodon_api/controllers/search_controller_test.exs | 2 +- test/web/push/impl_test.exs | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/activity_test.exs b/test/activity_test.exs index 0c19f481b..7c3f66da9 100644 --- a/test/activity_test.exs +++ b/test/activity_test.exs @@ -11,6 +11,11 @@ defmodule Pleroma.ActivityTest do alias Pleroma.ThreadMute 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 activity = insert(:note_activity) found_activity = Activity.get_by_ap_id(activity.data["id"]) @@ -107,8 +112,6 @@ test "when association is not loaded" do describe "search" do setup do - Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) - user = insert(:user) params = %{ diff --git a/test/web/mastodon_api/controllers/search_controller_test.exs b/test/web/mastodon_api/controllers/search_controller_test.exs index 02476acb6..8b9459735 100644 --- a/test/web/mastodon_api/controllers/search_controller_test.exs +++ b/test/web/mastodon_api/controllers/search_controller_test.exs @@ -13,7 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do import Tesla.Mock import Mock - setup do + setup_all do mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs index b855d72ba..57b35061a 100644 --- a/test/web/push/impl_test.exs +++ b/test/web/push/impl_test.exs @@ -13,8 +13,8 @@ defmodule Pleroma.Web.Push.ImplTest do import Pleroma.Factory - setup_all do - Tesla.Mock.mock_global(fn + setup do + Tesla.Mock.mock(fn %{method: :post, url: "https://example.com/example/1234"} -> %Tesla.Env{status: 200}