Top*_*unt 6 testing debugging elixir ecto phoenix-framework
我很乐意听取有关如何在Phoenix控制器测试中运行pry调试器的建议:
require IEx
在目标文件中IEx.pry
到所需的行iex -S mix test --trace
但几秒钟后,这个错误总是出现:
16:51:08.108 [error] Postgrex.Protocol (#PID<0.250.0>) disconnected:
** (DBConnection.ConnectionError) owner #PID<0.384.0> timed out because
it owned the connection for longer than 15000ms
Run Code Online (Sandbox Code Playgroud)
正如消息所示,此时数据库连接似乎超时,并且任何调用数据库连接的命令都会出错DBConnection.OwnershipError
.如何告诉我的数据库连接不要超时,以便我可以安静地调试我的测试?
该Ecto.Adapters.SQL.Sandbox常见问题提到了这个问题,并解释说,你可以将添加:ownership_timeout
设置将回购的配置,以指定长DB连接应该如何超时前继续开放。我将我的设置为 10 分钟(仅限测试环境),所以我再也不用考虑了:
# config.test.exs
config :rumbl, Rumbl.Repo,
# ...other settings...
ownership_timeout: 10 * 60 * 1000 # long timeout so pry sessions don't break
Run Code Online (Sandbox Code Playgroud)
正如预期的那样,我现在可以pry
在看到该错误之前闲逛10 分钟。
归档时间: |
|
查看次数: |
596 次 |
最近记录: |