summaryrefslogtreecommitdiff
path: root/test/web/push/impl_test.exs
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2020-09-22 13:37:02 -0500
committerAlex Gleason <alex@alexgleason.me>2020-09-22 13:37:02 -0500
commit3104367931bdd259752fb9e2b7a19ba42a72e614 (patch)
tree92d59fed02dded222d51e300269f8a742e4c9c05 /test/web/push/impl_test.exs
parentbf181ca96850f3e5baaf8f3dcd6e11b926fcdeeb (diff)
parent02f12ec6253093d8bedaf84d78d0f7e533745e1b (diff)
downloadpleroma-3104367931bdd259752fb9e2b7a19ba42a72e614.tar.gz
pleroma-3104367931bdd259752fb9e2b7a19ba42a72e614.zip
Merge remote-tracking branch 'upstream/develop' into email-fix-develop
Diffstat (limited to 'test/web/push/impl_test.exs')
-rw-r--r--test/web/push/impl_test.exs18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs
index aeb5c1fbd..c7c17e156 100644
--- a/test/web/push/impl_test.exs
+++ b/test/web/push/impl_test.exs
@@ -12,7 +12,9 @@ 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
@@ -78,6 +80,22 @@ 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(