diff options
author | href <href@random.sh> | 2018-01-31 20:36:42 +0100 |
---|---|---|
committer | href <href@random.sh> | 2018-01-31 20:36:42 +0100 |
commit | fcb2a082346054108f3f16cffe968450cf961976 (patch) | |
tree | 8e7d2eb9eeebf854e62e08c29b147f34dfeb1881 /test/support |
import
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/channel_case.ex | 33 | ||||
-rw-r--r-- | test/support/conn_case.ex | 34 |
2 files changed, 67 insertions, 0 deletions
diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex new file mode 100644 index 0000000..dcaa658 --- /dev/null +++ b/test/support/channel_case.ex @@ -0,0 +1,33 @@ +defmodule LSGWeb.ChannelCase do + @moduledoc """ + This module defines the test case to be used by + channel tests. + + Such tests rely on `Phoenix.ChannelTest` and also + import other functionality to make it easier + to build common datastructures and query the data layer. + + Finally, if the test case interacts with the database, + it cannot be async. For this reason, every test runs + inside a transaction which is reset at the beginning + of the test unless the test case is marked as async. + """ + + use ExUnit.CaseTemplate + + using do + quote do + # Import conveniences for testing with channels + use Phoenix.ChannelTest + + # The default endpoint for testing + @endpoint LSGWeb.Endpoint + end + end + + + setup _tags do + :ok + end + +end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex new file mode 100644 index 0000000..9ed8e53 --- /dev/null +++ b/test/support/conn_case.ex @@ -0,0 +1,34 @@ +defmodule LSGWeb.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 datastructures and query the data layer. + + Finally, if the test case interacts with the database, + it cannot be async. For this reason, every test runs + inside a transaction which is reset at the beginning + of the test unless the test case is marked as async. + """ + + use ExUnit.CaseTemplate + + using do + quote do + # Import conveniences for testing with connections + use Phoenix.ConnTest + import LSGWeb.Router.Helpers + + # The default endpoint for testing + @endpoint LSGWeb.Endpoint + end + end + + + setup _tags do + {:ok, conn: Phoenix.ConnTest.build_conn()} + end + +end |