From aa69db4798f60afac693cea37c78e76ee69d4f22 Mon Sep 17 00:00:00 2001 From: Ilja Date: Sun, 17 Jul 2022 19:04:44 +0100 Subject: [PATCH] Fix flaky test: nil/wrong values passed --- test/pleroma/web/activity_pub/activity_pub_test.exs | 2 ++ test/pleroma/web/common_api_test.exs | 2 ++ .../web/mastodon_api/controllers/media_controller_test.exs | 2 ++ .../web/mastodon_api/controllers/status_controller_test.exs | 2 ++ .../web/pleroma_api/controllers/chat_controller_test.exs | 3 +++ 5 files changed, 11 insertions(+) diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index a38d8a3fb..f85c4bbb8 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -23,6 +23,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do import Tesla.Mock setup do + clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + clear_config([Pleroma.Uploaders.Local, :uploads], "uploads") mock(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index 20870bdd7..85a4a3a11 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -27,6 +27,8 @@ defmodule Pleroma.Web.CommonAPITest do require Pleroma.Constants setup_all do + clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + clear_config([Pleroma.Uploaders.Local, :uploads], "uploads") Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end diff --git a/test/pleroma/web/mastodon_api/controllers/media_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/media_controller_test.exs index ff988a7fd..50b9febea 100644 --- a/test/pleroma/web/mastodon_api/controllers/media_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/media_controller_test.exs @@ -13,6 +13,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do describe "Upload media" do setup do: oauth_access(["write:media"]) + setup do: clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + setup do: clear_config([Pleroma.Uploaders.Local, :uploads], "uploads") setup do image = %Plug.Upload{ diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs index 3e0660031..c5d204358 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -25,6 +25,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do setup do: clear_config([:rich_media, :enabled]) setup do: clear_config([:mrf, :policies]) setup do: clear_config([:mrf_keyword, :reject]) + setup do: clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + setup do: clear_config([Pleroma.Uploaders.Local, :uploads], "uploads") describe "posting statuses" do setup do: oauth_access(["write:statuses"]) diff --git a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs index 99b0d43a7..a817a2dba 100644 --- a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs @@ -106,6 +106,9 @@ test "it fails if there is no content", %{conn: conn, user: user} do end test "it works with an attachment", %{conn: conn, user: user} do + clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + clear_config([Pleroma.Uploaders.Local, :uploads], "uploads") + file = %Plug.Upload{ content_type: "image/jpeg", path: Path.absname("test/fixtures/image.jpg"),