【问题标题】:Heroku tests started failing overnight? (cannot configure sandbox)Heroku 测试在一夜之间开始失败? (无法配置沙箱)
【发布时间】:2018-04-25 00:30:19
【问题描述】:

我在 Heroku 上运行测试时遇到了一个奇怪的错误,这在周五没有发生,本地一切正常。

-----> Running test command `mix test`...
  08:29:52.761 [info] Already up
  08:29:53.389 [info] seeding in prod environment
  08:29:53.389 [info] runing default seeds
  All departments inserted

  ** (RuntimeError) cannot configure sandbox with pool DBConnection.Poolboy.
  To use the SQL Sandbox, configure your repository pool as:
  pool: Ecto.Adapters.SQL.Sandbox
  (ecto) lib/ecto/adapters/sql/sandbox.ex:429: Ecto.Adapters.SQL.Sandbox.mode/2
  (elixir) lib/code.ex:376: Code.require_file/2
  (elixir) lib/enum.ex:675: Enum."-each/2-lists^foreach/1-0-"/2
  (elixir) lib/enum.ex:675: Enum.each/2
  (mix) lib/mix/tasks/test.ex:229: Mix.Tasks.Test.run/1
-----> test command `mix test` failed with exit status 1

几个月内测试配置没有变化……

# Configure your database
config :ev2, Ev2.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "postgres",
  password: "postgres",
  database: "ev2_timecards_test",
  hostname: "localhost",
  pool: Ecto.Adapters.SQL.Sandbox

app.json 目前看起来像这样:

"environments": {
"test": {
  "env": {
    "IS_STAGING": {
      "required": false
    }
  },
  "addons":[
    "heroku-postgresql:hobby-dev",
    "heroku-redis:hobby-dev"
  ],
  "scripts": {
    "test-setup": "mix ecto.migrate",
    "test": "mix test",
    "postdeploy": "bash <(curl -s https://codecov.io/bash)"
  }
}

}

使用 Phoenix 1.3 运行。

我想知道周一早上是否有人面临这个问题,或者是否有人有任何建议?

提前致谢!

【问题讨论】:

    标签: testing heroku elixir phoenix-framework


    【解决方案1】:

    在你的设置和测试脚本中设置 mix_env 进行测试:

          "scripts": {
            "test-setup": "MIX_ENV=test mix ecto.migrate",
            "test": "MIX_ENV=test mix test"
          }
    

    【讨论】:

      猜你喜欢
      • 2015-11-13
      • 1970-01-01
      • 2020-03-23
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-03
      • 2017-11-04
      相关资源
      最近更新 更多