Fix tests
This commit is contained in:
parent
6a9d9da26f
commit
5c8afbe646
@ -21,9 +21,7 @@ defmodule Pleroma.Web.Push.Impl do
|
|||||||
|
|
||||||
@doc "Builds webpush notification payloads for the subscriptions enabled by the receiving user"
|
@doc "Builds webpush notification payloads for the subscriptions enabled by the receiving user"
|
||||||
@spec build(Notification.t()) ::
|
@spec build(Notification.t()) ::
|
||||||
list(%{content: map(), subscription: Subscription.t()})
|
list(%{content: map(), subscription: Subscription.t()}) | []
|
||||||
| :error
|
|
||||||
| {:error, :unknown_type}
|
|
||||||
def build(
|
def build(
|
||||||
%{
|
%{
|
||||||
activity: %{data: %{"type" => activity_type}} = activity,
|
activity: %{data: %{"type" => activity_type}} = activity,
|
||||||
@ -62,9 +60,9 @@ defmodule Pleroma.Web.Push.Impl do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build(_) do
|
def build(notif) do
|
||||||
Logger.warning("Unknown notification type")
|
Logger.warning("WebPush: unknown activity type: #{inspect(notif)}")
|
||||||
{:error, :unknown_type}
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "Deliver push notification to the provided webpush subscription"
|
@doc "Deliver push notification to the provided webpush subscription"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
defmodule Pleroma.Web.Push.ImplTest do
|
defmodule Pleroma.Web.Push.ImplTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: true
|
||||||
|
|
||||||
|
import ExUnit.CaptureLog
|
||||||
import Mox
|
import Mox
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
@ -62,8 +63,10 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
@tag capture_log: true
|
||||||
test "returns error if notif does not match " do
|
test "returns error if notification activity type does not match" do
|
||||||
assert Impl.build(%{}) == {:error, :unknown_type}
|
assert capture_log(fn ->
|
||||||
|
assert Impl.build(%{}) == []
|
||||||
|
end) =~ "WebPush: unknown activity type"
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
@tag capture_log: true
|
||||||
|
Loading…
Reference in New Issue
Block a user