Set uploader to Pleroma.Uploaders.Local for failing tests

There were tests who were failing with

```
     The following arguments were given to IO.chardata_to_string/1:

         # 1
         nil

     Attempted function clauses (showing 2 out of 2):

         def chardata_to_string(string) when is_binary(string)
         def chardata_to_string(list) when is_list(list)
```

I noticed for several of them the problem was that the uploader was set to S3, while the rest of the S3 settings were nil.
The uploader itself didn't really matter much for the tests, but if it throws errors because it has settings that can't work, then the test fails.
I made changed the uploader to local first.
This commit is contained in:
Ilja 2022-07-16 13:13:20 +02:00
parent 3fb9171694
commit a4097e0802
5 changed files with 11 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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{

View file

@ -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"])

View file

@ -106,6 +106,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest 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"),