stop connections manually

This commit is contained in:
Alexander Strizhakov 2020-03-02 10:01:07 +03:00
parent 2622cf1190
commit 137c600cae
No known key found for this signature in database
GPG key ID: 022896A53AEF1381

View file

@ -23,11 +23,18 @@ defmodule Pleroma.Pool.ConnectionsTest do
name = :test_connections name = :test_connections
adapter = Application.get_env(:tesla, :adapter) adapter = Application.get_env(:tesla, :adapter)
Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun) Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun)
on_exit(fn -> Application.put_env(:tesla, :adapter, adapter) end)
{:ok, _pid} = {:ok, pid} =
Connections.start_link({name, [max_connections: 2, receive_connection_timeout: 1_500]}) Connections.start_link({name, [max_connections: 2, receive_connection_timeout: 1_500]})
on_exit(fn ->
Application.put_env(:tesla, :adapter, adapter)
if Process.alive?(pid) do
GenServer.stop(name)
end
end)
{:ok, name: name} {:ok, name: name}
end end