Skip to content

Instantly share code, notes, and snippets.

@gjaldon
Last active April 28, 2017 09:58
Show Gist options
  • Save gjaldon/c16adf92c8d0fa59ac0488b35c293528 to your computer and use it in GitHub Desktop.
Save gjaldon/c16adf92c8d0fa59ac0488b35c293528 to your computer and use it in GitHub Desktop.
## conn_case.ex code
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Reporting.RepoWrite)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Profilix.RepoRead)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(ACL.RepoRead)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Reporting.RepoWrite, {:shared, self()})
Ecto.Adapters.SQL.Sandbox.mode(Profilix.RepoRead, {:shared, self()})
Ecto.Adapters.SQL.Sandbox.mode(ACL.RepoRead, {:shared, self()})
end
user = RepoRead.insert!(%ProfilixUser{id: 1, display_name: "Foo"})
conn = Phoenix.ConnTest.build_conn()
|> Plug.Conn.put_req_header("accept", "application/json")
|> Plug.Conn.put_req_header("authorization", "Bearer #{jwt}")
{:ok, conn: conn, user: user}
end
## test_helper.exs
ExUnit.start
Ecto.Adapters.SQL.Sandbox.mode(Reporting.RepoWrite, :manual)
Ecto.Adapters.SQL.Sandbox.mode(Profilix.RepoRead, :manual)
Ecto.Adapters.SQL.Sandbox.mode(ACL.RepoRead, :manual)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment