init SlideLife
This commit is contained in:
@ -1,14 +0,0 @@
|
||||
defmodule ModernBaseWeb.ErrorHTMLTest do
|
||||
use ModernBaseWeb.ConnCase, async: true
|
||||
|
||||
# Bring render_to_string/4 for testing custom views
|
||||
import Phoenix.Template
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(ModernBaseWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(ModernBaseWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
defmodule ModernBaseWeb.ErrorJSONTest do
|
||||
use ModernBaseWeb.ConnCase, async: true
|
||||
|
||||
test "renders 404" do
|
||||
assert ModernBaseWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
||||
end
|
||||
|
||||
test "renders 500" do
|
||||
assert ModernBaseWeb.ErrorJSON.render("500.json", %{}) ==
|
||||
%{errors: %{detail: "Internal Server Error"}}
|
||||
end
|
||||
end
|
14
test/slide_life_web/controllers/error_html_test.exs
Normal file
14
test/slide_life_web/controllers/error_html_test.exs
Normal file
@ -0,0 +1,14 @@
|
||||
defmodule SlideLifeWeb.ErrorHTMLTest do
|
||||
use SlideLifeWeb.ConnCase, async: true
|
||||
|
||||
# Bring render_to_string/4 for testing custom views
|
||||
import Phoenix.Template
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(SlideLifeWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(SlideLifeWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
12
test/slide_life_web/controllers/error_json_test.exs
Normal file
12
test/slide_life_web/controllers/error_json_test.exs
Normal file
@ -0,0 +1,12 @@
|
||||
defmodule SlideLifeWeb.ErrorJSONTest do
|
||||
use SlideLifeWeb.ConnCase, async: true
|
||||
|
||||
test "renders 404" do
|
||||
assert SlideLifeWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
||||
end
|
||||
|
||||
test "renders 500" do
|
||||
assert SlideLifeWeb.ErrorJSON.render("500.json", %{}) ==
|
||||
%{errors: %{detail: "Internal Server Error"}}
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
defmodule ModernBaseWeb.PageControllerTest do
|
||||
use ModernBaseWeb.ConnCase
|
||||
defmodule SlideLifeWeb.PageControllerTest do
|
||||
use SlideLifeWeb.ConnCase
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
@ -1,4 +1,4 @@
|
||||
defmodule ModernBaseWeb.ConnCase do
|
||||
defmodule SlideLifeWeb.ConnCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
tests that require setting up a connection.
|
||||
@ -11,7 +11,7 @@ defmodule ModernBaseWeb.ConnCase do
|
||||
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 ModernBaseWeb.ConnCase, async: true`, although
|
||||
by setting `use SlideLifeWeb.ConnCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@ -20,19 +20,19 @@ defmodule ModernBaseWeb.ConnCase do
|
||||
using do
|
||||
quote do
|
||||
# The default endpoint for testing
|
||||
@endpoint ModernBaseWeb.Endpoint
|
||||
@endpoint SlideLifeWeb.Endpoint
|
||||
|
||||
use ModernBaseWeb, :verified_routes
|
||||
use SlideLifeWeb, :verified_routes
|
||||
|
||||
# Import conveniences for testing with connections
|
||||
import Plug.Conn
|
||||
import Phoenix.ConnTest
|
||||
import ModernBaseWeb.ConnCase
|
||||
import SlideLifeWeb.ConnCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
ModernBase.DataCase.setup_sandbox(tags)
|
||||
SlideLife.DataCase.setup_sandbox(tags)
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
defmodule ModernBase.DataCase do
|
||||
defmodule SlideLife.DataCase do
|
||||
@moduledoc """
|
||||
This module defines the setup for tests requiring
|
||||
access to the application's data layer.
|
||||
@ -10,7 +10,7 @@ defmodule ModernBase.DataCase do
|
||||
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 ModernBase.DataCase, async: true`, although
|
||||
by setting `use SlideLife.DataCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@ -18,17 +18,17 @@ defmodule ModernBase.DataCase do
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias ModernBase.Repo
|
||||
alias SlideLife.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import ModernBase.DataCase
|
||||
import SlideLife.DataCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
ModernBase.DataCase.setup_sandbox(tags)
|
||||
SlideLife.DataCase.setup_sandbox(tags)
|
||||
:ok
|
||||
end
|
||||
|
||||
@ -36,7 +36,7 @@ defmodule ModernBase.DataCase do
|
||||
Sets up the sandbox based on the test tags.
|
||||
"""
|
||||
def setup_sandbox(tags) do
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(ModernBase.Repo, shared: not tags[:async])
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(SlideLife.Repo, shared: not tags[:async])
|
||||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
||||
end
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
ExUnit.start()
|
||||
Ecto.Adapters.SQL.Sandbox.mode(ModernBase.Repo, :manual)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(SlideLife.Repo, :manual)
|
||||
|
Reference in New Issue
Block a user