Changeset View
Changeset View
Standalone View
Standalone View
test/support/conn_case.ex
defmodule KolabChat.ConnCase do | defmodule KolabChat.Web.ConnCase do | ||||
@moduledoc """ | @moduledoc """ | ||||
This module defines the test case to be used by | This module defines the test case to be used by | ||||
tests that require setting up a connection. | tests that require setting up a connection. | ||||
Such tests rely on `Phoenix.ConnTest` and also | Such tests rely on `Phoenix.ConnTest` and also | ||||
import other functionality to make it easier | import other functionality to make it easier | ||||
to build and query models. | to build and query models. | ||||
Show All 10 Lines | quote do | ||||
# Import conveniences for testing with connections | # Import conveniences for testing with connections | ||||
use Phoenix.ConnTest | use Phoenix.ConnTest | ||||
alias KolabChat.Repo | alias KolabChat.Repo | ||||
import Ecto | import Ecto | ||||
import Ecto.Changeset | import Ecto.Changeset | ||||
import Ecto.Query | import Ecto.Query | ||||
import KolabChat.Router.Helpers | import KolabChat.Web.Router.Helpers | ||||
# The default endpoint for testing | # The default endpoint for testing | ||||
@endpoint KolabChat.Endpoint | @endpoint KolabChat.Web.Endpoint | ||||
end | end | ||||
end | end | ||||
setup tags do | setup tags do | ||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(KolabChat.Repo) | :ok = Ecto.Adapters.SQL.Sandbox.checkout(KolabChat.Repo) | ||||
unless tags[:async] do | unless tags[:async] do | ||||
Ecto.Adapters.SQL.Sandbox.mode(KolabChat.Repo, {:shared, self()}) | Ecto.Adapters.SQL.Sandbox.mode(KolabChat.Repo, {:shared, self()}) | ||||
end | end | ||||
{:ok, conn: Phoenix.ConnTest.build_conn()} | {:ok, conn: Phoenix.ConnTest.build_conn()} | ||||
end | end | ||||
end | end |