forked from AkkomaGang/akkoma
Merge branch 'fix/1742-random-failing-tests' into 'develop'
Fix sporadically failing tests See merge request pleroma/pleroma!2524
This commit is contained in:
commit
da550be066
10 changed files with 45 additions and 51 deletions
test
|
@ -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 = %{
|
||||
|
|
|
@ -43,11 +43,9 @@ test "get_all_as_keyword/0" 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ test "send pleroma user agent" 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"}]
|
||||
|
|
|
@ -58,7 +58,7 @@ test "it returns path with bucket namespace when namespace is set" 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]
|
||||
|
|
|
@ -2862,26 +2862,25 @@ test "proxy tuple localhost", %{conn: conn} 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 @@ test "proxy tuple domain", %{conn: conn} 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 @@ test "proxy tuple ip", %{conn: conn} 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
|
||||
|
||||
|
|
|
@ -138,8 +138,8 @@ test "gets a feed (RSS)", %{conn: conn} 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) == [
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue