In an effort to decouple things, I made a phoenix 1.3 umbrella project with no ecto. I just put ecto layer in a self contained elixir module, used by a json api on the phoenix web side.
I even can use contexts inside this db layer module, or use it with absinthe/graphql.
While it is working nicely, I think I may have gone a little too far in decoupling. My main concern is when I start to test the API, it will populate my real database… not a sandboxed one.
I don’t really want to mock up things between 2 modules of the same umbrella.
Is there a method to tell my database layer to use a sandboxed test db, from the phoenix api test suite?
Thanks for taking time
test config you should still have the config for it set to the testing style database?
For me it is this setting in the
test.exs for the database:
Thank You @OvermindDL1 for pointing me in the right direction.
I just generated a “normal” umbrella phoenix project and had a look at the configuration.
I have to reproduce this config, because it is not done automatically the way I generated the decoupled project.
It should be possible, because in the usual way, there is already decoupling between the web interface and the main project module
Again, thank You for your help.
If it’s decoupled like you say it is, then why not just make a
GenServer that implements your db layer API?
Take a look at this blog post José wrote awhile back.
Hello @azolo, it is mostly because I didn’t wanted to mock up things if there is a way to configure testing.
It is decoupled, but there is still coupling at the controller level, which use contexts functions from db layer.
Thank You for your help.