forked from pow-auth/pow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_helper.exs
30 lines (22 loc) · 1.03 KB
/
test_helper.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Logger.configure(level: :warn)
ExUnit.start()
# Ensure that symlink to custom ecto priv directory exists
source = Pow.Test.Ecto.Repo.config()[:priv]
target = Application.app_dir(:pow, source)
File.rm_rf(target)
File.mkdir_p(target)
File.rmdir(target)
:ok = :file.make_symlink(Path.expand(source), target)
Mix.Task.run("ecto.drop", ~w(--quiet -r Pow.Test.Ecto.Repo))
Mix.Task.run("ecto.create", ~w(--quiet -r Pow.Test.Ecto.Repo))
Mix.Task.run("ecto.migrate", ~w(--quiet -r Pow.Test.Ecto.Repo))
{:ok, _pid} = Pow.Test.Ecto.Repo.start_link()
Ecto.Adapters.SQL.Sandbox.mode(Pow.Test.Ecto.Repo, :manual)
{:ok, _pid} = Pow.Test.Phoenix.Endpoint.start_link()
for extension <- Application.get_env(:pow, :extension_test_modules) do
endpoint_module = Module.concat([extension, TestWeb.Phoenix.Endpoint])
Application.put_env(:pow, endpoint_module,
render_errors: [view: Pow.Test.Phoenix.ErrorView, accepts: ~w(html json)],
secret_key_base: String.duplicate("abcdefghijklmnopqrstuvxyz0123456789", 2))
{:ok, _pid} = endpoint_module.start_link()
end