April 2019
Beginner to intermediate
244 pages
6h 34m
English
To use the sandbox, change your Repo configuration to use the sandbox pool. We only want to do this when we’re in our test environment, so make the following change in config/test.exs and only there:
| | config :music_db, MusicDB.Repo, |
| | pool: Ecto.Adapters.SQL.Sandbox |
| | # other settings here |
By changing the pool: setting, we’re telling Ecto that we will not be using the default connection pool and instead give the sandbox full control over how connections are checked out and used by processes.
Next, we need to set our sandbox to the correct ownership mode. We’ll cover this setting in more detail later, but for now, add this line to test/test_helper.exs:
| | Ecto.Adapters.SQL.Sandbox.mode(MusicDB.Repo, ... |
Read now
Unlock full access