init SlideLife

This commit is contained in:
2024-05-21 23:48:50 +02:00
parent c21f4ab218
commit a988eb4bc2
37 changed files with 154 additions and 176 deletions

View File

@ -1,4 +1,4 @@
defmodule ModernBase.DataCase do
defmodule SlideLife.DataCase do
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
@ -10,7 +10,7 @@ defmodule ModernBase.DataCase do
we enable the SQL sandbox, so changes done to the database
are reverted at the end of every test. If you are using
PostgreSQL, you can even run database tests asynchronously
by setting `use ModernBase.DataCase, async: true`, although
by setting `use SlideLife.DataCase, async: true`, although
this option is not recommended for other databases.
"""
@ -18,17 +18,17 @@ defmodule ModernBase.DataCase do
using do
quote do
alias ModernBase.Repo
alias SlideLife.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
import ModernBase.DataCase
import SlideLife.DataCase
end
end
setup tags do
ModernBase.DataCase.setup_sandbox(tags)
SlideLife.DataCase.setup_sandbox(tags)
:ok
end
@ -36,7 +36,7 @@ defmodule ModernBase.DataCase do
Sets up the sandbox based on the test tags.
"""
def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(ModernBase.Repo, shared: not tags[:async])
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(SlideLife.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
end