Merge branch 'feature/create-tombstone-instead-of-delete' into 'develop'
[akkoma] / test / support / channel_case.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ChannelCase do
6 @moduledoc """
7 This module defines the test case to be used by
8 channel tests.
9
10 Such tests rely on `Phoenix.ChannelTest` and also
11 import other functionality to make it easier
12 to build common datastructures and query the data layer.
13
14 Finally, if the test case interacts with the database,
15 it cannot be async. For this reason, every test runs
16 inside a transaction which is reset at the beginning
17 of the test unless the test case is marked as async.
18 """
19
20 use ExUnit.CaseTemplate
21
22 using do
23 quote do
24 # Import conveniences for testing with channels
25 use Phoenix.ChannelTest
26
27 # The default endpoint for testing
28 @endpoint Pleroma.Web.Endpoint
29 end
30 end
31
32 setup tags do
33 :ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
34
35 unless tags[:async] do
36 Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
37 end
38
39 :ok
40 end
41 end