removing integration tests
This commit is contained in:
parent
058c9b01ac
commit
931111fd55
4 changed files with 0 additions and 460 deletions
|
|
@ -1,93 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ReverseProxy.Client.TeslaTest do
|
||||
use ExUnit.Case
|
||||
use Pleroma.Tests.Helpers
|
||||
alias Pleroma.ReverseProxy.Client
|
||||
@moduletag :integration
|
||||
|
||||
clear_config_all(Pleroma.Gun) do
|
||||
Pleroma.Config.put(Pleroma.Gun, Pleroma.Gun.API)
|
||||
end
|
||||
|
||||
setup do
|
||||
Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun)
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:tesla, :adapter, Tesla.Mock)
|
||||
end)
|
||||
end
|
||||
|
||||
test "get response body stream" do
|
||||
{:ok, status, headers, ref} =
|
||||
Client.Tesla.request(
|
||||
:get,
|
||||
"http://httpbin.org/stream-bytes/10",
|
||||
[{"accept", "application/octet-stream"}],
|
||||
"",
|
||||
[]
|
||||
)
|
||||
|
||||
assert status == 200
|
||||
assert headers != []
|
||||
|
||||
{:ok, response, ref} = Client.Tesla.stream_body(ref)
|
||||
check_ref(ref)
|
||||
assert is_binary(response)
|
||||
assert byte_size(response) == 10
|
||||
|
||||
assert :done == Client.Tesla.stream_body(ref)
|
||||
assert :ok = Client.Tesla.close(ref)
|
||||
end
|
||||
|
||||
test "head response" do
|
||||
{:ok, status, headers} = Client.Tesla.request(:head, "https://httpbin.org/get", [], "")
|
||||
|
||||
assert status == 200
|
||||
assert headers != []
|
||||
end
|
||||
|
||||
test "get error response" do
|
||||
{:ok, status, headers, _body} =
|
||||
Client.Tesla.request(
|
||||
:get,
|
||||
"https://httpbin.org/status/500",
|
||||
[],
|
||||
""
|
||||
)
|
||||
|
||||
assert status == 500
|
||||
assert headers != []
|
||||
end
|
||||
|
||||
describe "client error" do
|
||||
setup do
|
||||
adapter = Application.get_env(:tesla, :adapter)
|
||||
Application.put_env(:tesla, :adapter, Tesla.Adapter.Hackney)
|
||||
|
||||
on_exit(fn -> Application.put_env(:tesla, :adapter, adapter) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "adapter doesn't support reading body in chunks" do
|
||||
assert_raise RuntimeError,
|
||||
"Elixir.Tesla.Adapter.Hackney doesn't support reading body in chunks",
|
||||
fn ->
|
||||
Client.Tesla.request(
|
||||
:get,
|
||||
"http://httpbin.org/stream-bytes/10",
|
||||
[{"accept", "application/octet-stream"}],
|
||||
""
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp check_ref(%{pid: pid, stream: stream} = ref) do
|
||||
assert is_pid(pid)
|
||||
assert is_reference(stream)
|
||||
assert ref[:fin]
|
||||
end
|
||||
end
|
||||
|
|
@ -341,45 +341,4 @@ defmodule Pleroma.ReverseProxyTest do
|
|||
assert {"content-disposition", "attachment; filename=\"filename.jpg\""} in conn.resp_headers
|
||||
end
|
||||
end
|
||||
|
||||
describe "tesla client using gun integration" do
|
||||
@describetag :integration
|
||||
|
||||
clear_config(Pleroma.ReverseProxy.Client) do
|
||||
Pleroma.Config.put(Pleroma.ReverseProxy.Client, Pleroma.ReverseProxy.Client.Tesla)
|
||||
end
|
||||
|
||||
clear_config(Pleroma.Gun) do
|
||||
Pleroma.Config.put(Pleroma.Gun, Pleroma.Gun.API)
|
||||
end
|
||||
|
||||
setup do
|
||||
adapter = Application.get_env(:tesla, :adapter)
|
||||
Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun)
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:tesla, :adapter, adapter)
|
||||
end)
|
||||
end
|
||||
|
||||
test "common", %{conn: conn} do
|
||||
conn = ReverseProxy.call(conn, "http://httpbin.org/stream-bytes/10")
|
||||
assert byte_size(conn.resp_body) == 10
|
||||
assert conn.state == :chunked
|
||||
assert conn.status == 200
|
||||
end
|
||||
|
||||
test "ssl", %{conn: conn} do
|
||||
conn = ReverseProxy.call(conn, "https://httpbin.org/stream-bytes/10")
|
||||
assert byte_size(conn.resp_body) == 10
|
||||
assert conn.state == :chunked
|
||||
assert conn.status == 200
|
||||
end
|
||||
|
||||
test "follow redirects", %{conn: conn} do
|
||||
conn = ReverseProxy.call(conn, "https://httpbin.org/redirect/5")
|
||||
assert conn.state == :chunked
|
||||
assert conn.status == 200
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue