test fixes

This commit is contained in:
Alex S 2019-08-19 16:27:59 +03:00
parent 814159e668
commit 05ca6a7d2c
3 changed files with 13 additions and 5 deletions

View File

@ -46,7 +46,7 @@ defmodule Pleroma.Gun.Connections do
# TODO: only for testing, add this parameter to the config
@spec try_to_get_gun_conn(String.t(), keyword(), atom()) :: nil | pid()
def try_to_get_gun_conn(url, opts \\ [], name \\ __MODULE__),
def try_to_get_gun_conn(url, opts \\ [], name \\ :default),
do: try_to_get_gun_conn(url, opts, name, 0)
@spec try_to_get_gun_conn(String.t(), keyword(), atom(), pos_integer()) :: nil | pid()

View File

@ -62,7 +62,9 @@ defmodule Pleroma.HTTP do
end
defp get_conn_for_gun(url, options) do
case Pleroma.Gun.Connections.get_conn(url, options) do
pool = if options[:adapter][:pool], do: options[:adapter][:pool], else: :default
case Pleroma.Gun.Connections.try_to_get_gun_conn(url, options, pool) do
nil ->
options

View File

@ -356,7 +356,9 @@ defmodule Pleroma.ReverseProxyTest do
api = Pleroma.Config.get([Pleroma.Gun.API])
Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun)
{:ok, _} = Pleroma.Gun.Connections.start_link(Pleroma.Gun.Connections)
{:ok, _} =
Pleroma.Gun.Connections.start_link({:media, [max_connections: 5, timeout: 5_000]})
conn = ReverseProxy.call(conn, "http://httpbin.org/stream-bytes/10")
@ -379,7 +381,9 @@ defmodule Pleroma.ReverseProxyTest do
api = Pleroma.Config.get([Pleroma.Gun.API])
Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun)
{:ok, _} = Pleroma.Gun.Connections.start_link(Pleroma.Gun.Connections)
{:ok, _} =
Pleroma.Gun.Connections.start_link({:media, [max_connections: 5, timeout: 5_000]})
conn = ReverseProxy.call(conn, "https://httpbin.org/stream-bytes/10")
@ -402,7 +406,9 @@ defmodule Pleroma.ReverseProxyTest do
api = Pleroma.Config.get([Pleroma.Gun.API])
Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun)
{:ok, _} = Pleroma.Gun.Connections.start_link(Pleroma.Gun.Connections)
{:ok, _} =
Pleroma.Gun.Connections.start_link({:media, [max_connections: 5, timeout: 5_000]})
conn = ReverseProxy.call(conn, "https://httpbin.org/redirect/5")