don't run tests which change env in async

This commit is contained in:
Alexander Strizhakov 2020-05-11 15:07:05 +03:00
parent 4ba913d641
commit 712055612f
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
2 changed files with 29 additions and 36 deletions

View file

@ -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 @@ defmodule Pleroma.HTTP.RequestBuilderTest 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"}]

View file

@ -2862,26 +2862,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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