summaryrefslogtreecommitdiff
path: root/test/support/repo_case.ex
diff options
context:
space:
mode:
Diffstat (limited to 'test/support/repo_case.ex')
-rw-r--r--test/support/repo_case.ex25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/support/repo_case.ex b/test/support/repo_case.ex
new file mode 100644
index 0000000..73abcff
--- /dev/null
+++ b/test/support/repo_case.ex
@@ -0,0 +1,25 @@
+defmodule Chessh.RepoCase do
+ use ExUnit.CaseTemplate
+
+ using do
+ quote do
+ alias Chessh.Repo
+
+ import Ecto
+ import Ecto.Query
+ import Chessh.RepoCase
+
+ # and any other stuff
+ end
+ end
+
+ setup tags do
+ :ok = Ecto.Adapters.SQL.Sandbox.checkout(Chessh.Repo)
+
+ unless tags[:async] do
+ Ecto.Adapters.SQL.Sandbox.mode(Chessh.Repo, {:shared, self()})
+ end
+
+ :ok
+ end
+end