conn_case.ex 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. defmodule FourlettersWeb.ConnCase do
  2. @moduledoc """
  3. This module defines the test case to be used by
  4. tests that require setting up a connection.
  5. Such tests rely on `Phoenix.ConnTest` 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 FourlettersWeb.ConnCase, 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 connections
  19. import Plug.Conn
  20. import Phoenix.ConnTest
  21. import FourlettersWeb.ConnCase
  22. alias FourlettersWeb.Router.Helpers, as: Routes
  23. # The default endpoint for testing
  24. @endpoint FourlettersWeb.Endpoint
  25. end
  26. end
  27. setup _tags do
  28. {:ok, conn: Phoenix.ConnTest.build_conn()}
  29. end
  30. end