2020-02-11 02:12:57 -05:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 18:16:24 -05:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2020-02-11 02:12:57 -05:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-03-03 10:53:44 -05:00
|
|
|
defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
|
2020-03-06 12:23:58 -05:00
|
|
|
use ExUnit.Case, async: true
|
2020-02-11 02:12:57 -05:00
|
|
|
use Pleroma.Tests.Helpers
|
|
|
|
|
2020-03-03 10:53:44 -05:00
|
|
|
alias Pleroma.HTTP.AdapterHelper.Hackney
|
2020-02-11 02:12:57 -05:00
|
|
|
|
|
|
|
setup_all do
|
|
|
|
uri = URI.parse("http://domain.com")
|
|
|
|
{:ok, uri: uri}
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "options/2" do
|
2020-03-20 13:58:47 -04:00
|
|
|
setup do: clear_config([:http, :adapter], a: 1, b: 2)
|
2020-02-11 02:12:57 -05:00
|
|
|
|
|
|
|
test "add proxy and opts from config", %{uri: uri} do
|
2020-03-06 12:23:58 -05:00
|
|
|
opts = Hackney.options([proxy: "localhost:8123"], uri)
|
2020-02-11 02:12:57 -05:00
|
|
|
|
|
|
|
assert opts[:a] == 1
|
|
|
|
assert opts[:b] == 2
|
|
|
|
assert opts[:proxy] == "localhost:8123"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "respect connection opts and no proxy", %{uri: uri} do
|
|
|
|
opts = Hackney.options([a: 2, b: 1], uri)
|
|
|
|
|
|
|
|
assert opts[:a] == 2
|
|
|
|
assert opts[:b] == 1
|
|
|
|
refute Keyword.has_key?(opts, :proxy)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|