diff options
Diffstat (limited to 'test/http_test.exs')
-rw-r--r-- | test/http_test.exs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/http_test.exs b/test/http_test.exs index 5f9522cf0..b88e3b605 100644 --- a/test/http_test.exs +++ b/test/http_test.exs @@ -56,4 +56,33 @@ defmodule Pleroma.HTTPTest do } end end + + @tag :integration + test "get_conn_for_gun/3" do + adapter = Application.get_env(:tesla, :adapter) + Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun) + api = Pleroma.Config.get([Pleroma.Gun.API]) + Pleroma.Config.put([Pleroma.Gun.API], Pleroma.Gun.API.Gun) + + on_exit(fn -> + Application.put_env(:tesla, :adapter, adapter) + Pleroma.Config.put([Pleroma.Gun.API], api) + end) + + options = [adapter: [pool: :federation]] + + assert {:ok, resp} = Pleroma.HTTP.get("https://httpbin.org/user-agent", [], options) + + adapter_opts = resp.opts[:adapter] + + assert resp.status == 200 + + assert adapter_opts[:url] == "https://httpbin.org/user-agent" + state = Pleroma.Gun.Connections.get_state(:federation) + conn = state.conns["https:httpbin.org:443"] + + assert conn.conn_state == :idle + assert conn.used_by == [] + assert state.queue == [] + end end |