channel_case.ex 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. defmodule OpenpodWeb.ChannelCase do
  2. @moduledoc """
  3. This module defines the test case to be used by
  4. channel tests.
  5. Such tests rely on `Phoenix.ChannelTest` and also
  6. import other functionality to make it easier
  7. to build common data structures and query the data layer.
  8. Finally, if the test case interacts with the database,
  9. we enable the SQL sandbox, so changes done to the database
  10. are reverted at the end of every test. If you are using
  11. PostgreSQL, you can even run database tests asynchronously
  12. by setting `use OpenpodWeb.ChannelCase, async: true`, although
  13. this option is not recommended for other databases.
  14. """
  15. use ExUnit.CaseTemplate
  16. using do
  17. quote do
  18. # Import conveniences for testing with channels
  19. import Phoenix.ChannelTest
  20. import OpenpodWeb.ChannelCase
  21. # The default endpoint for testing
  22. @endpoint OpenpodWeb.Endpoint
  23. end
  24. end
  25. setup tags do
  26. # :ok = Ecto.Adapters.SQL.Sandbox.checkout(Openpod.Repo)
  27. # unless tags[:async] do
  28. # Ecto.Adapters.SQL.Sandbox.mode(Openpod.Repo, {:shared, self()})
  29. # end
  30. :ok
  31. end
  32. end