aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/support/web_push_http_client_mock.ex23
-rw-r--r--test/web/push/impl_test.exs22
2 files changed, 2 insertions, 43 deletions
diff --git a/test/support/web_push_http_client_mock.ex b/test/support/web_push_http_client_mock.ex
deleted file mode 100644
index 3cd12957d..000000000
--- a/test/support/web_push_http_client_mock.ex
+++ /dev/null
@@ -1,23 +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.Web.WebPushHttpClientMock do
- def get(url, headers \\ [], options \\ []) do
- {
- res,
- %Tesla.Env{status: status}
- } = Pleroma.HTTP.request(:get, url, "", headers, options)
-
- {res, %{status_code: status}}
- end
-
- def post(url, body, headers \\ [], options \\ []) do
- {
- res,
- %Tesla.Env{status: status}
- } = Pleroma.HTTP.request(:post, url, body, headers, options)
-
- {res, %{status_code: status}}
- end
-end
diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs
index c7c17e156..6cab46696 100644
--- a/test/web/push/impl_test.exs
+++ b/test/web/push/impl_test.exs
@@ -5,6 +5,8 @@
defmodule Pleroma.Web.Push.ImplTest do
use Pleroma.DataCase
+ import Pleroma.Factory
+
alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.User
@@ -12,10 +14,6 @@ defmodule Pleroma.Web.Push.ImplTest do
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Push.Impl
alias Pleroma.Web.Push.Subscription
- alias Pleroma.Web.WebPushHttpClientMock
-
- import Mock
- import Pleroma.Factory
setup do
Tesla.Mock.mock(fn
@@ -80,22 +78,6 @@ defmodule Pleroma.Web.Push.ImplTest do
assert Impl.push_message(@message, @sub, @api_key, %Subscription{}) == :ok
end
- test_with_mock "uses WebPushHttpClientMock as an HTTP client", WebPushHttpClientMock,
- post: fn _, _, _ -> {:ok, %{status_code: 200}} end do
- Impl.push_message(@message, @sub, @api_key, %Subscription{})
- assert_called(WebPushHttpClientMock.post("https://example.com/example/1234", :_, :_))
- end
-
- test_with_mock "uses Pleroma.HTTP as an HTTP client", Pleroma.HTTP,
- post: fn _, _, _ -> {:ok, %{status_code: 200}} end do
- client = Application.get_env(:web_push_encryption, :http_client)
- on_exit(fn -> Application.put_env(:web_push_encryption, :http_client, client) end)
- Application.put_env(:web_push_encryption, :http_client, Pleroma.HTTP)
-
- Impl.push_message(@message, @sub, @api_key, %Subscription{})
- assert_called(Pleroma.HTTP.post("https://example.com/example/1234", :_, :_))
- end
-
@tag capture_log: true
test "fail message sending" do
assert Impl.push_message(