Phoenix.Sync.Sandbox.Postgres (Phoenix.Sync v0.6.1)
View SourceSummary
Functions
Replace hard-coded references to Ecto.Adapters.Postgres with this macro to
enable the Phoenix.Sync.Sandbox in test mode.
Functions
Replace hard-coded references to Ecto.Adapters.Postgres with this macro to
enable the Phoenix.Sync.Sandbox in test mode.
In development or production environments the repo will use the standard
Postgres adapter directly, only if Mix.env() == :test (see below) will it
use the sandbox adapter shim.
Example:
defmodule MyApp.Repo do
use Phoenix.Sync.Sandbox.Postgres
use Ecto.Repo,
otp_app: :my_app,
adapter: Phoenix.Sync.Sandbox.Postgres.adapter()
endCustom environments
If you want to enable the sandbox adapter in different environments, you can use your own evaluation logic:
defmodule MyApp.Repo do
use Phoenix.Sync.Sandbox.Postgres
use Ecto.Repo,
otp_app: :my_app,
adapter: Phoenix.Sync.Sandbox.Postgres.adapter(Mix.env() in [:test, :special])
endWarning
The expression passed to adapter/1 will be evaluated at compile time,
not run-time so only use expressions that can be evaluated at then (this
includes the various Mix functions).