use ExUnit.Case, async: true
use Pleroma.Tests.Helpers
- import ExUnit.CaptureLog
import Mox
alias Pleroma.Config
end
describe "options/1" do
- clear_config([:http, :adapter]) do
- Config.put([:http, :adapter], a: 1, b: 2)
- end
+ setup do: clear_config([:http, :adapter], a: 1, b: 2)
test "https url with default port" do
uri = URI.parse("https://example.com")
opts = Gun.options([receive_conn: false], uri)
assert opts[:certificates_verification]
- assert opts[:transport] == :tls
end
test "get conn on next request" do
on_exit(fn -> Logger.configure(level: level) end)
uri = URI.parse("http://some-domain2.com")
- assert capture_log(fn ->
- opts = Gun.options(uri)
+ opts = Gun.options(uri)
- assert opts[:conn] == nil
- assert opts[:close_conn] == nil
- end) =~
- "Gun connections pool checkin was not successful. Trying to open conn for next request."
+ assert opts[:conn] == nil
+ assert opts[:close_conn] == nil
+ Process.sleep(50)
opts = Gun.options(uri)
assert is_pid(opts[:conn])