adapter renaming to adapter_helper
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Tue, 3 Mar 2020 15:53:44 +0000 (18:53 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Tue, 3 Mar 2020 15:53:44 +0000 (18:53 +0300)
lib/pleroma/http/adapter_helper.ex [moved from lib/pleroma/http/adapter.ex with 96% similarity]
lib/pleroma/http/adapter_helper/gun.ex [moved from lib/pleroma/http/adapter/gun.ex with 94% similarity]
lib/pleroma/http/adapter_helper/hackney.ex [moved from lib/pleroma/http/adapter/hackney.ex with 87% similarity]
lib/pleroma/http/connection.ex
test/http/adapter_helper/gun_test.exs [moved from test/http/adapter/gun_test.exs with 99% similarity]
test/http/adapter_helper/hackney_test.exs [moved from test/http/adapter/hackney_test.exs with 93% similarity]
test/http/adapter_helper_test.exs [new file with mode: 0644]
test/http/adapter_test.exs [deleted file]

similarity index 96%
rename from lib/pleroma/http/adapter.ex
rename to lib/pleroma/http/adapter_helper.ex
index a3b84d8f32e748f884a285507f011968f0c62dcb..2c13666ecebff86375d4555a37d7fe13a9ac628f 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.HTTP.Adapter do
+defmodule Pleroma.HTTP.AdapterHelper do
   alias Pleroma.HTTP.Connection
 
   @type proxy ::
similarity index 94%
rename from lib/pleroma/http/adapter/gun.ex
rename to lib/pleroma/http/adapter_helper/gun.ex
index ecf9c5b62e56c47aa5d008ffd09f5697048592c8..b3298ec7fbf33dbe56a0a7917ad872ebdf3ed6e4 100644 (file)
@@ -2,10 +2,10 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.HTTP.Adapter.Gun do
-  @behaviour Pleroma.HTTP.Adapter
+defmodule Pleroma.HTTP.AdapterHelper.Gun do
+  @behaviour Pleroma.HTTP.AdapterHelper
 
-  alias Pleroma.HTTP.Adapter
+  alias Pleroma.HTTP.AdapterHelper
 
   require Logger
 
@@ -28,7 +28,7 @@ defmodule Pleroma.HTTP.Adapter.Gun do
     |> Keyword.merge(Pleroma.Config.get([:http, :adapter], []))
     |> add_original(uri)
     |> add_scheme_opts(uri)
-    |> Adapter.maybe_add_proxy(Adapter.format_proxy(proxy))
+    |> AdapterHelper.maybe_add_proxy(AdapterHelper.format_proxy(proxy))
     |> maybe_get_conn(uri, connection_opts)
   end
 
similarity index 87%
rename from lib/pleroma/http/adapter/hackney.ex
rename to lib/pleroma/http/adapter_helper/hackney.ex
index 00db30083e509bf0401b3a1e7ee4f92c1a62e9f9..a0e161eaa27b245eba90a3fb72c9b582e28c73e2 100644 (file)
@@ -1,5 +1,5 @@
-defmodule Pleroma.HTTP.Adapter.Hackney do
-  @behaviour Pleroma.HTTP.Adapter
+defmodule Pleroma.HTTP.AdapterHelper.Hackney do
+  @behaviour Pleroma.HTTP.AdapterHelper
 
   @defaults [
     connect_timeout: 10_000,
@@ -17,7 +17,7 @@ defmodule Pleroma.HTTP.Adapter.Hackney do
     |> Keyword.merge(Pleroma.Config.get([:http, :adapter], []))
     |> Keyword.merge(connection_opts)
     |> add_scheme_opts(uri)
-    |> Pleroma.HTTP.Adapter.maybe_add_proxy(proxy)
+    |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
   end
 
   defp add_scheme_opts(opts, %URI{scheme: "http"}), do: opts
index bdd062929a7a8dadaaad4f5b15c855a9f142c837..dc2761182a86716f55a5d28874b30440f5a9af56 100644 (file)
@@ -18,7 +18,7 @@ defmodule Pleroma.HTTP.Connection do
   require Logger
 
   alias Pleroma.Config
-  alias Pleroma.HTTP.Adapter
+  alias Pleroma.HTTP.AdapterHelper
 
   @doc """
   Merge default connection & adapter options with received ones.
@@ -50,9 +50,9 @@ defmodule Pleroma.HTTP.Connection do
 
   defp adapter do
     case Application.get_env(:tesla, :adapter) do
-      Tesla.Adapter.Gun -> Adapter.Gun
-      Tesla.Adapter.Hackney -> Adapter.Hackney
-      _ -> Adapter
+      Tesla.Adapter.Gun -> AdapterHelper.Gun
+      Tesla.Adapter.Hackney -> AdapterHelper.Hackney
+      _ -> AdapterHelper
     end
   end
 
similarity index 99%
rename from test/http/adapter/gun_test.exs
rename to test/http/adapter_helper/gun_test.exs
index a05471ac67f766e49f912541f42257fd01657cf9..bc7e3f0e03d324102c005be4801d43e4010df832 100644 (file)
@@ -2,13 +2,13 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.HTTP.Adapter.GunTest do
+defmodule Pleroma.HTTP.AdapterHelper.GunTest do
   use ExUnit.Case, async: true
   use Pleroma.Tests.Helpers
   import ExUnit.CaptureLog
   alias Pleroma.Config
   alias Pleroma.Gun.Conn
-  alias Pleroma.HTTP.Adapter.Gun
+  alias Pleroma.HTTP.AdapterHelper.Gun
   alias Pleroma.Pool.Connections
 
   setup_all do
similarity index 93%
rename from test/http/adapter/hackney_test.exs
rename to test/http/adapter_helper/hackney_test.exs
index 35cb581258adc494e3f7531a4b761bc2d49de521..82f5a7883cc131f3bae8d633ef9ee03eb77a47c5 100644 (file)
@@ -2,12 +2,12 @@
 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.HTTP.Adapter.HackneyTest do
+defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
   use ExUnit.Case
   use Pleroma.Tests.Helpers
 
   alias Pleroma.Config
-  alias Pleroma.HTTP.Adapter.Hackney
+  alias Pleroma.HTTP.AdapterHelper.Hackney
 
   setup_all do
     uri = URI.parse("http://domain.com")
diff --git a/test/http/adapter_helper_test.exs b/test/http/adapter_helper_test.exs
new file mode 100644 (file)
index 0000000..24d501a
--- /dev/null
@@ -0,0 +1,28 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.HTTP.AdapterHelperTest do
+  use ExUnit.Case, async: true
+
+  alias Pleroma.HTTP.AdapterHelper
+
+  describe "format_proxy/1" do
+    test "with nil" do
+      assert AdapterHelper.format_proxy(nil) == nil
+    end
+
+    test "with string" do
+      assert AdapterHelper.format_proxy("127.0.0.1:8123") == {{127, 0, 0, 1}, 8123}
+    end
+
+    test "localhost with port" do
+      assert AdapterHelper.format_proxy("localhost:8123") == {'localhost', 8123}
+    end
+
+    test "tuple" do
+      assert AdapterHelper.format_proxy({:socks4, :localhost, 9050}) ==
+               {:socks4, 'localhost', 9050}
+    end
+  end
+end
diff --git a/test/http/adapter_test.exs b/test/http/adapter_test.exs
deleted file mode 100644 (file)
index 4c80583..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.HTTP.AdapterTest do
-  use ExUnit.Case, async: true
-
-  alias Pleroma.HTTP.Adapter
-
-  describe "format_proxy/1" do
-    test "with nil" do
-      assert Adapter.format_proxy(nil) == nil
-    end
-
-    test "with string" do
-      assert Adapter.format_proxy("127.0.0.1:8123") == {{127, 0, 0, 1}, 8123}
-    end
-
-    test "localhost with port" do
-      assert Adapter.format_proxy("localhost:8123") == {'localhost', 8123}
-    end
-
-    test "tuple" do
-      assert Adapter.format_proxy({:socks4, :localhost, 9050}) == {:socks4, 'localhost', 9050}
-    end
-  end
-end