Skip to content

Commit

Permalink
Add test for badly formed FCM notification
Browse files Browse the repository at this point in the history
  • Loading branch information
zofpolkowska committed Dec 18, 2019
1 parent 3a715bd commit 26c49aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/common/api/v3_fcm_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ defmodule MongoosePush.API.V3FCMTest do

assert {200, nil} == Tools.post(@url, Tools.sample_notification(:fcm))
end

@tag integration: true
test "push to fcm with bad notification format fails" do
desc = "OK"

Tools.reset(:fcm)

assert {400, %{"reason" => "invalid_notification"}} ==
Tools.post(@url, Tools.sample_bad_notification(:fcm))
end
end
15 changes: 15 additions & 0 deletions test/support/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ defmodule MongoosePush.Support.API do
}
end

def sample_bad_notification(service) do
%{
:service => service,
:alert => %{
:title => "title value",
:body => "body value",
:click_action => "click.action",
:tag => "tag value"
},
:data => %{
:x => [["a", "b"], 1, "c"]
}
}
end

def post(path, json) do
%Response{status_code: status_code, body: body} =
HTTPoison.post!(
Expand Down

0 comments on commit 26c49aa

Please sign in to comment.