Compare commits

...

3 commits

Author SHA1 Message Date
Ilja cc468513d1 Merge branch 'fix_flaky_nil_provided_to_functions_who_expect_string' into 'develop'
Draft: Fix flaky test: default S3 uploader values make code fail

See merge request pleroma/pleroma!3700
2024-04-13 20:02:45 +00:00
Ilja 8a16504ce1 set upload to local for failing tests
All of these turned out to also have their upload set to S3 with default values.
That made the tests fail because the default S3 values don't work.
2022-07-18 10:58:46 +02:00
Ilja a4097e0802 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.
2022-07-16 13:13:20 +02:00
7 changed files with 16 additions and 1 deletions

View file

@ -25,6 +25,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)
ConfigMock

View file

@ -36,6 +36,8 @@ defmodule Pleroma.Web.CommonAPITest do
end
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,9 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
setup do: clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
setup do: clear_config([Pleroma.Uploaders.Local, :uploads], "uploads")
describe "Upload media" do
setup do: oauth_access(["write:media"])

View file

@ -27,6 +27,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
setup do: clear_config([:instance, :allow_relay])
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")
setup do
Pleroma.UnstubbedConfigMock

View file

@ -10,7 +10,8 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
alias Pleroma.Web.PleromaAPI.BackupView
setup do
clear_config([Pleroma.Upload, :uploader])
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([Pleroma.Uploaders.Local, :uploads], "uploads")
clear_config([Backup, :limit_days])
ConfigMock

View file

@ -109,6 +109,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"),

View file

@ -430,6 +430,8 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
test "with media proxy" do
clear_config([:media_proxy, :enabled], true)
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([Pleroma.Uploaders.Local, :uploads], "uploads")
ConfigMock
|> stub_with(Pleroma.Test.StaticConfig)