logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

hackney_test.exs (941B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
  5. use ExUnit.Case, async: true
  6. use Pleroma.Tests.Helpers
  7. alias Pleroma.HTTP.AdapterHelper.Hackney
  8. setup_all do
  9. uri = URI.parse("http://domain.com")
  10. {:ok, uri: uri}
  11. end
  12. describe "options/2" do
  13. setup do: clear_config([:http, :adapter], a: 1, b: 2)
  14. test "add proxy and opts from config", %{uri: uri} do
  15. opts = Hackney.options([proxy: "localhost:8123"], uri)
  16. assert opts[:a] == 1
  17. assert opts[:b] == 2
  18. assert opts[:proxy] == "localhost:8123"
  19. end
  20. test "respect connection opts and no proxy", %{uri: uri} do
  21. opts = Hackney.options([a: 2, b: 1], uri)
  22. assert opts[:a] == 2
  23. assert opts[:b] == 1
  24. refute Keyword.has_key?(opts, :proxy)
  25. end
  26. end
  27. end