First
[anni] / test / pleroma / http / adapter_helper_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.HTTP.AdapterHelperTest do
6   use ExUnit.Case, async: true
7
8   alias Pleroma.HTTP.AdapterHelper
9
10   describe "format_proxy/1" do
11     test "with nil" do
12       assert AdapterHelper.format_proxy(nil) == nil
13     end
14
15     test "with string" do
16       assert AdapterHelper.format_proxy("127.0.0.1:8123") == {{127, 0, 0, 1}, 8123}
17     end
18
19     test "localhost with port" do
20       assert AdapterHelper.format_proxy("localhost:8123") == {'localhost', 8123}
21     end
22
23     test "tuple" do
24       assert AdapterHelper.format_proxy({:socks4, :localhost, 9050}) ==
25                {:socks4, 'localhost', 9050}
26     end
27   end
28 end