In my mix.exs
I have set up the following during development:
defp aliases do
[
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.drop", "ecto.create", "ecto.migrate", "run priv/repo/test_seeds.exs", "test"]
]
end
2 things to notice: 1) I drop my test database and re-create it for test runs because 2) I have a set of seeds that I use only for the tests. I know, I could have used fixtures to do that, but it got really onerous with highly-interrelated data, so I thought it would be easier to just have a seed file with my “curated” boilerplate test data.
Then I had this horrible thought: what if I tried to run tests on production? How does mix
know which environment you’re in when running the mix
tasks? Is what I’ve done bad form?
Thanks as always for pointers/feedback.