diff --git a/test/activity_test.exs b/test/activity_test.exs index 507027e5a..2a92327d1 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 @@ defmodule Pleroma.ActivityTest 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/config/config_db_test.exs b/test/config/config_db_test.exs index 6b0e7b4b6..a8e947365 100644 --- a/test/config/config_db_test.exs +++ b/test/config/config_db_test.exs @@ -43,11 +43,9 @@ defmodule Pleroma.ConfigDBTest do {ConfigDB.from_string(saved.key), ConfigDB.from_binary(saved.value)} ] - assert config[:quack] == [ - level: :info, - meta: [:none], - webhook_url: "https://hooks.slack.com/services/KEY/some_val" - ] + assert config[:quack][:level] == :info + assert config[:quack][:meta] == [:none] + assert config[:quack][:webhook_url] == "https://hooks.slack.com/services/KEY/some_val" end describe "update_or_create/1" do diff --git a/test/http/connection_test.exs b/test/http/connection_test.exs index 5cc78ad5b..7c94a50b2 100644 --- a/test/http/connection_test.exs +++ b/test/http/connection_test.exs @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP.ConnectionTest do - use ExUnit.Case, async: true + use ExUnit.Case use Pleroma.Tests.Helpers import ExUnit.CaptureLog diff --git a/test/http/request_builder_test.exs b/test/http/request_builder_test.exs index f11528c3f..fab909905 100644 --- a/test/http/request_builder_test.exs +++ b/test/http/request_builder_test.exs @@ -3,23 +3,19 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP.RequestBuilderTest do - use ExUnit.Case, async: true + use ExUnit.Case use Pleroma.Tests.Helpers - alias Pleroma.Config alias Pleroma.HTTP.Request alias Pleroma.HTTP.RequestBuilder describe "headers/2" do - setup do: clear_config([:http, :send_user_agent]) - setup do: clear_config([:http, :user_agent]) - test "don't send pleroma user agent" do assert RequestBuilder.headers(%Request{}, []) == %Request{headers: []} end test "send pleroma user agent" do - Config.put([:http, :send_user_agent], true) - Config.put([:http, :user_agent], :default) + clear_config([:http, :send_user_agent], true) + clear_config([:http, :user_agent], :default) assert RequestBuilder.headers(%Request{}, []) == %Request{ headers: [{"user-agent", Pleroma.Application.user_agent()}] @@ -27,8 +23,8 @@ defmodule Pleroma.HTTP.RequestBuilderTest do end test "send custom user agent" do - Config.put([:http, :send_user_agent], true) - Config.put([:http, :user_agent], "totally-not-pleroma") + clear_config([:http, :send_user_agent], true) + clear_config([:http, :user_agent], "totally-not-pleroma") assert RequestBuilder.headers(%Request{}, []) == %Request{ headers: [{"user-agent", "totally-not-pleroma"}] diff --git a/test/uploaders/s3_test.exs b/test/uploaders/s3_test.exs index 6950ccb25..d949c90a5 100644 --- a/test/uploaders/s3_test.exs +++ b/test/uploaders/s3_test.exs @@ -58,7 +58,7 @@ defmodule Pleroma.Uploaders.S3Test do name: "image-tet.jpg", content_type: "image/jpg", path: "test_folder/image-tet.jpg", - tempfile: Path.absname("test/fixtures/image_tmp.jpg") + tempfile: Path.absname("test/instance_static/add/shortcode.png") } [file_upload: file_upload] diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index ecf5465be..e4b0dd627 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -2862,26 +2862,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do group: ":pleroma", key: ":http", value: [ - %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]}, - %{"tuple" => [":send_user_agent", false]} + %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]} ] } ] }) - assert json_response(conn, 200) == %{ + assert %{ "configs" => [ %{ "group" => ":pleroma", "key" => ":http", - "value" => [ - %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]}, - %{"tuple" => [":send_user_agent", false]} - ], - "db" => [":proxy_url", ":send_user_agent"] + "value" => value, + "db" => db } ] - } + } = json_response(conn, 200) + + assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]} in value + assert ":proxy_url" in db end test "proxy tuple domain", %{conn: conn} do @@ -2892,26 +2891,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do group: ":pleroma", key: ":http", value: [ - %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]}, - %{"tuple" => [":send_user_agent", false]} + %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]} ] } ] }) - assert json_response(conn, 200) == %{ + assert %{ "configs" => [ %{ "group" => ":pleroma", "key" => ":http", - "value" => [ - %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]}, - %{"tuple" => [":send_user_agent", false]} - ], - "db" => [":proxy_url", ":send_user_agent"] + "value" => value, + "db" => db } ] - } + } = json_response(conn, 200) + + assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]} in value + assert ":proxy_url" in db end test "proxy tuple ip", %{conn: conn} do @@ -2922,26 +2920,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do group: ":pleroma", key: ":http", value: [ - %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]}, - %{"tuple" => [":send_user_agent", false]} + %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]} ] } ] }) - assert json_response(conn, 200) == %{ + assert %{ "configs" => [ %{ "group" => ":pleroma", "key" => ":http", - "value" => [ - %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]}, - %{"tuple" => [":send_user_agent", false]} - ], - "db" => [":proxy_url", ":send_user_agent"] + "value" => value, + "db" => db } ] - } + } = json_response(conn, 200) + + assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]} in value + assert ":proxy_url" in db end end diff --git a/test/web/feed/tag_controller_test.exs b/test/web/feed/tag_controller_test.exs index a54161bd4..3c29cd94f 100644 --- a/test/web/feed/tag_controller_test.exs +++ b/test/web/feed/tag_controller_test.exs @@ -138,8 +138,8 @@ defmodule Pleroma.Web.Feed.TagControllerTest do ] assert xpath(xml, ~x"//channel/item/pubDate/text()"sl) == [ - FeedView.pub_date(activity1.data["published"]), - FeedView.pub_date(activity2.data["published"]) + FeedView.pub_date(activity2.data["published"]), + FeedView.pub_date(activity1.data["published"]) ] assert xpath(xml, ~x"//channel/item/enclosure/@url"sl) == [ diff --git a/test/web/mastodon_api/controllers/search_controller_test.exs b/test/web/mastodon_api/controllers/search_controller_test.exs index 6ad9a59fe..7d0cafccc 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 2fc3e73b5..2acd0939f 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} diff --git a/test/web/rel_me_test.exs b/test/web/rel_me_test.exs index e05a8863d..65255916d 100644 --- a/test/web/rel_me_test.exs +++ b/test/web/rel_me_test.exs @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.RelMeTest do - use ExUnit.Case, async: true + use ExUnit.Case setup_all do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)