-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0eb7517
commit 5c93e2b
Showing
6 changed files
with
64 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
defmodule MongoosePushWeb.ConnCase do | ||
@moduledoc """ | ||
This module defines the test case to be used by | ||
tests that require setting up a connection. | ||
Such tests rely on `Phoenix.ConnTest` and also | ||
import other functionality to make it easier | ||
to build common data structures and query the data layer. | ||
Finally, if the test case interacts with the database, | ||
we enable the SQL sandbox, so changes done to the database | ||
are reverted at the end of every test. If you are using | ||
PostgreSQL, you can even run database tests asynchronously | ||
by setting `use MpushDummyWeb.ConnCase, async: true`, although | ||
this option is not recommended for other databases. | ||
""" | ||
|
||
use ExUnit.CaseTemplate | ||
|
||
using do | ||
quote do | ||
# Import conveniences for testing with connections | ||
use Phoenix.ConnTest | ||
alias MongoosePushWeb.Router.Helpers, as: Routes | ||
|
||
# The default endpoint for testing | ||
@endpoint MongoosePushWeb.Endpoint | ||
end | ||
end | ||
|
||
setup _tags do | ||
{:ok, conn: Phoenix.ConnTest.build_conn()} | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule MongoosePushWeb.ApiControllerTest do | ||
use MongoosePushWeb.ConnCase | ||
alias MongoosePushWeb.Router.Helpers, as: Routes | ||
|
||
setup %{conn: conn} do | ||
TestHelper.reload_app() | ||
conn = conn | ||
|> put_req_header("accept", "application/json") | ||
|> put_req_header("content-type", "application/json") | ||
{:ok, conn: conn} | ||
end | ||
|
||
test "POST /simple", %{conn: conn} do | ||
body = %{service: :fcm, body: "body", title: "title"} | ||
json = Poison.encode!(body) | ||
conn = post(conn, "/simple", json) | ||
json_response(conn, 200) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ExUnit.start() | ||
|
||
defmodule TestHelper do | ||
def reload_app() do | ||
Application.stop(:mongoose_push) | ||
{:ok, _} = Application.ensure_all_started(:mongoose_push) | ||
:ok | ||
end | ||
end |