LionelMarco
In previous Phoenix version I have been running test in my database without any sandbox and everyting run well.
Because already we have a specific database for development,configured in: config/test.exs
Now upgrade Phoenix and a new feature appear Sandbox
So I want to make all changes insert, update, delete, persistent.
I read this post but it is not was usefull for me:
I don’t want to use Shared mode:
I just only want to remove the sanbox an work in the database
Please can somebody tell me wich is the right way.
This is a part from my test.exs:
import Config
config :gis, Gis.Repo,
username: "gisuser",
password: "gisuser",
hostname: "localhost",
database: "gisapp" , #{System.get_env("MIX_TEST_PARTITION")}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: 10
How to configure pool argument to use NO sandbox ?
What must to write to directly use my Repo
Or may be need to change : connn_case.ex file
I try removing the next line from test_helpers.exs
# Ecto.Adapters.SQL.Sandbox.mode(Gis.Repo, :manual)
and remove:
#pool: Ecto.Adapters.SQL.Sandbox,
from config/test.exs
But nothing happen
Also the documentation does not say anything of how to disable it.
please can anybody tell me how to proceed ?
Greetings
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
@LionelMarco Simply replace the
config :gis, Gis.Repocontents with the same stuff you have in dev, but change the database to whatever you want to use for your test db.However there are some things that are confusing me here:
The Ecto Sandbox is not a Phoenix feature, it’s an ecto feature. It’s also opt in so simply upgrading ecto will not add it to your project. If you were not using it before, how did it end up in your project at all?
dimitarvp
Are you really really sure you want that? You can just as well just seed / populate your test DB to have baseline data that you need – that’s a legitimate need, a good amount of applications cannot run adequate tests on an empty DB – and then proceed to run tests in the normal sandboxed manner.
LionelMarco
can’t delete this
dimitarvp
Saw your edit – no need to delete.
If you need different seeds then just make different seed scripts? Easy enough, just put them in
priv/repo/seeds/and then fill up the test DB withMIX_ENV=test mix run priv/repo/seeds/team_one_seeds.exsfor example.LionelMarco
Yes SandBox is a Ecto feature was a misundertanding error.
Copy the code from dev.exs is exactly what I tried:
my test.exs:
If I run: mix test
I get a lot of errors like that:
And if I run : mix test ./test/data_layer_test.exs
I get:
Also there is a file named “test_helpers.exs”
I tried commenting the second line but nothing happen.
What should I do with him?
What cant be wrong ??
LostKobrakai
Search for all calls on
Ecto.Adapters.SQL.Sandboxfunctions. The one intest_helpers.exsis not the only one. Though like others I’d suggest validating if that’s indeed the best way forward. Manually maintaining db state across tests can easily become a problem.benwilson512
Again I want to ask how your project got in this state? Upgrading Ecto does not magically introduce the sandbox into your project.
LionelMarco
Ben, my main goal was to update Phoenix to version 1.7. in order to use Core components, it is the only reason, so:
mix archive.install hex phx_new 1.7.7mix phx.new gisappCan you tell me if I can downgrade to a version without sandbox ?
Also there is a file : test/support/data_case.ex
where the sand box is started or configured, is there any way to turn off it,
Why something that should be so easy like:
with_sand_box: false
Is not implemented ?
I am used to work just with Cowboy, and it does not have sandbox in test.
Greetings
dimitarvp
There is no such version. Also that’s a feature of Ecto, not a feature of Phoenix.
Because having a persistent test DB is a bad practice.
You never answered the questions why do you need this. I’m willing to bet you’ll be better off with the sandbox.
LionelMarco
I do work for a company that distributes gas to homes with more than 2,000,000 homes, there are many areas, measurement, billing, payments, accounting, etc. There is a specific database for development, totally isolated from production. To test each area needs the data from the previous one. And each area tests in due time. In times unrelated to those of the others.
Each test involves thousands of items that are created and stored procedures that must be executed. This takes a lot of time.
This is the working methodology, it may not be the correct one, but it is the one we use.
when configured the database in test.exs Is there any way to set another kind of pool ? that work without transaction ?