ZabGo
Issue when running tests: (Mix.Error) The database for Copi.Repo couldn't be created: killed
Hello,
I’m new to Elixir development. I’ve started to contribute to a website written with the Phoenix framework.
When I run the command mix test, most of the tests are failing. I suspect it’s because my test environment is not set up properly. Indeed, when I run an individual test I’ve got the following error message:
Mix task exited with reason
an exception was raised:
** (Mix.Error) The database for Copi.Repo couldn't be created: killed
(mix 1.16.0) lib/mix.ex:580: Mix.raise/2
(elixir 1.16.0) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
(mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.16.0) lib/mix/task.ex:544: Mix.Task.run_alias/6
(debug_adapter 0.20.0) lib/debug_adapter/server.ex:1969: ElixirLS.DebugAdapter.Server.launch_task/1
returning code 1
11:15:00.361 [error] Process #PID<0.491.0> raised an exception
** (Mix.Error) The database for Copi.Repo couldn't be created: killed
(mix 1.16.0) lib/mix.ex:580: Mix.raise/2
(elixir 1.16.0) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
(mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.16.0) lib/mix/task.ex:544: Mix.Task.run_alias/6
(debug_adapter 0.20.0) lib/debug_adapter/server.ex:1969: ElixirLS.DebugAdapter.Server.launch_task/1
The dev environment is working fine. I can launch the website and add data to the database.
Do I miss something to set up the test environment?
Thank you for you help. ![]()
Most Liked
emadb
Seems like that the tests cannot reach the database. Is it running? The connection url for test env is correct?
If it works in dev mode you can try run the application in test env:
MIX_ENV=test iex -S mix
Doing so could help in finding the problem.
arcanemachine
One solution I’ve experienced is to make sure you’re exporting your environment variables.
For example, this might not work:
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
mix test
But this might:
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
mix test
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










