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
|
@ -11,6 +11,11 @@ defmodule Pleroma.ActivityTest do
|
||||||
alias Pleroma.ThreadMute
|
alias Pleroma.ThreadMute
|
||||||
import Pleroma.Factory
|
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
|
test "returns an activity by it's AP id" do
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
found_activity = Activity.get_by_ap_id(activity.data["id"])
|
found_activity = Activity.get_by_ap_id(activity.data["id"])
|
||||||
|
@ -107,8 +112,6 @@ test "when association is not loaded" do
|
||||||
|
|
||||||
describe "search" do
|
describe "search" do
|
||||||
setup do
|
setup do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
|
||||||
|
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
params = %{
|
params = %{
|
||||||
|
|
|
@ -43,11 +43,9 @@ test "get_all_as_keyword/0" do
|
||||||
{ConfigDB.from_string(saved.key), ConfigDB.from_binary(saved.value)}
|
{ConfigDB.from_string(saved.key), ConfigDB.from_binary(saved.value)}
|
||||||
]
|
]
|
||||||
|
|
||||||
assert config[:quack] == [
|
assert config[:quack][:level] == :info
|
||||||
level: :info,
|
assert config[:quack][:meta] == [:none]
|
||||||
meta: [:none],
|
assert config[:quack][:webhook_url] == "https://hooks.slack.com/services/KEY/some_val"
|
||||||
webhook_url: "https://hooks.slack.com/services/KEY/some_val"
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update_or_create/1" do
|
describe "update_or_create/1" do
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.HTTP.ConnectionTest do
|
defmodule Pleroma.HTTP.ConnectionTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case
|
||||||
use Pleroma.Tests.Helpers
|
use Pleroma.Tests.Helpers
|
||||||
|
|
||||||
import ExUnit.CaptureLog
|
import ExUnit.CaptureLog
|
||||||
|
|
|
@ -3,23 +3,19 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.HTTP.RequestBuilderTest do
|
defmodule Pleroma.HTTP.RequestBuilderTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case
|
||||||
use Pleroma.Tests.Helpers
|
use Pleroma.Tests.Helpers
|
||||||
alias Pleroma.Config
|
|
||||||
alias Pleroma.HTTP.Request
|
alias Pleroma.HTTP.Request
|
||||||
alias Pleroma.HTTP.RequestBuilder
|
alias Pleroma.HTTP.RequestBuilder
|
||||||
|
|
||||||
describe "headers/2" do
|
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
|
test "don't send pleroma user agent" do
|
||||||
assert RequestBuilder.headers(%Request{}, []) == %Request{headers: []}
|
assert RequestBuilder.headers(%Request{}, []) == %Request{headers: []}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "send pleroma user agent" do
|
test "send pleroma user agent" do
|
||||||
Config.put([:http, :send_user_agent], true)
|
clear_config([:http, :send_user_agent], true)
|
||||||
Config.put([:http, :user_agent], :default)
|
clear_config([:http, :user_agent], :default)
|
||||||
|
|
||||||
assert RequestBuilder.headers(%Request{}, []) == %Request{
|
assert RequestBuilder.headers(%Request{}, []) == %Request{
|
||||||
headers: [{"user-agent", Pleroma.Application.user_agent()}]
|
headers: [{"user-agent", Pleroma.Application.user_agent()}]
|
||||||
|
@ -27,8 +23,8 @@ test "send pleroma user agent" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "send custom user agent" do
|
test "send custom user agent" do
|
||||||
Config.put([:http, :send_user_agent], true)
|
clear_config([:http, :send_user_agent], true)
|
||||||
Config.put([:http, :user_agent], "totally-not-pleroma")
|
clear_config([:http, :user_agent], "totally-not-pleroma")
|
||||||
|
|
||||||
assert RequestBuilder.headers(%Request{}, []) == %Request{
|
assert RequestBuilder.headers(%Request{}, []) == %Request{
|
||||||
headers: [{"user-agent", "totally-not-pleroma"}]
|
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",
|
name: "image-tet.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpg",
|
||||||
path: "test_folder/image-tet.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]
|
[file_upload: file_upload]
|
||||||
|
|
|
@ -2862,26 +2862,25 @@ test "proxy tuple localhost", %{conn: conn} do
|
||||||
group: ":pleroma",
|
group: ":pleroma",
|
||||||
key: ":http",
|
key: ":http",
|
||||||
value: [
|
value: [
|
||||||
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]},
|
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]}
|
||||||
%{"tuple" => [":send_user_agent", false]}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
assert json_response(conn, 200) == %{
|
assert %{
|
||||||
"configs" => [
|
"configs" => [
|
||||||
%{
|
%{
|
||||||
"group" => ":pleroma",
|
"group" => ":pleroma",
|
||||||
"key" => ":http",
|
"key" => ":http",
|
||||||
"value" => [
|
"value" => value,
|
||||||
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]},
|
"db" => db
|
||||||
%{"tuple" => [":send_user_agent", false]}
|
|
||||||
],
|
|
||||||
"db" => [":proxy_url", ":send_user_agent"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
} = json_response(conn, 200)
|
||||||
|
|
||||||
|
assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]} in value
|
||||||
|
assert ":proxy_url" in db
|
||||||
end
|
end
|
||||||
|
|
||||||
test "proxy tuple domain", %{conn: conn} do
|
test "proxy tuple domain", %{conn: conn} do
|
||||||
|
@ -2892,26 +2891,25 @@ test "proxy tuple domain", %{conn: conn} do
|
||||||
group: ":pleroma",
|
group: ":pleroma",
|
||||||
key: ":http",
|
key: ":http",
|
||||||
value: [
|
value: [
|
||||||
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]},
|
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]}
|
||||||
%{"tuple" => [":send_user_agent", false]}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
assert json_response(conn, 200) == %{
|
assert %{
|
||||||
"configs" => [
|
"configs" => [
|
||||||
%{
|
%{
|
||||||
"group" => ":pleroma",
|
"group" => ":pleroma",
|
||||||
"key" => ":http",
|
"key" => ":http",
|
||||||
"value" => [
|
"value" => value,
|
||||||
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]},
|
"db" => db
|
||||||
%{"tuple" => [":send_user_agent", false]}
|
|
||||||
],
|
|
||||||
"db" => [":proxy_url", ":send_user_agent"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
} = json_response(conn, 200)
|
||||||
|
|
||||||
|
assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]} in value
|
||||||
|
assert ":proxy_url" in db
|
||||||
end
|
end
|
||||||
|
|
||||||
test "proxy tuple ip", %{conn: conn} do
|
test "proxy tuple ip", %{conn: conn} do
|
||||||
|
@ -2922,26 +2920,25 @@ test "proxy tuple ip", %{conn: conn} do
|
||||||
group: ":pleroma",
|
group: ":pleroma",
|
||||||
key: ":http",
|
key: ":http",
|
||||||
value: [
|
value: [
|
||||||
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]},
|
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]}
|
||||||
%{"tuple" => [":send_user_agent", false]}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
assert json_response(conn, 200) == %{
|
assert %{
|
||||||
"configs" => [
|
"configs" => [
|
||||||
%{
|
%{
|
||||||
"group" => ":pleroma",
|
"group" => ":pleroma",
|
||||||
"key" => ":http",
|
"key" => ":http",
|
||||||
"value" => [
|
"value" => value,
|
||||||
%{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]},
|
"db" => db
|
||||||
%{"tuple" => [":send_user_agent", false]}
|
|
||||||
],
|
|
||||||
"db" => [":proxy_url", ":send_user_agent"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
} = json_response(conn, 200)
|
||||||
|
|
||||||
|
assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]} in value
|
||||||
|
assert ":proxy_url" in db
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,8 @@ test "gets a feed (RSS)", %{conn: conn} do
|
||||||
]
|
]
|
||||||
|
|
||||||
assert xpath(xml, ~x"//channel/item/pubDate/text()"sl) == [
|
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) == [
|
assert xpath(xml, ~x"//channel/item/enclosure/@url"sl) == [
|
||||||
|
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
import Mock
|
import Mock
|
||||||
|
|
||||||
setup do
|
setup_all do
|
||||||
mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,8 @@ defmodule Pleroma.Web.Push.ImplTest do
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
setup_all do
|
setup do
|
||||||
Tesla.Mock.mock_global(fn
|
Tesla.Mock.mock(fn
|
||||||
%{method: :post, url: "https://example.com/example/1234"} ->
|
%{method: :post, url: "https://example.com/example/1234"} ->
|
||||||
%Tesla.Env{status: 200}
|
%Tesla.Env{status: 200}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.RelMeTest do
|
defmodule Pleroma.Web.RelMeTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
Loading…
Reference in New Issue