【问题标题】:lein test with-profile unable to override test profile's env valuelein test with-profile 无法覆盖测试配置文件的 env 值
【发布时间】:2018-06-20 17:04:37
【问题描述】:

我正在做一些 Clojure 宠物项目。我有一些类似以下的个人资料

{:test   {:env {:database-name     "library_test",
                :host-name         "192.168.33.10"
                :username          "library_admin"
                :password          ""
                :dbtype            "postgres"
                :driver-class-name "org.postgresql.Driver"}},
 :dev    {:env {:database-name     "library",
                :host-name         "192.168.33.10"
                :username          "library_admin"
                :password          ""
                :dbtype            "postgres"
                :driver-class-name "org.postgresql.Driver"}},
 :travis {:env {:database-name     "test_library_test",
                :host-name         "localhost"
                :username          "test_user"
                :password          "password"
                :dbtype            "postgres"
                :driver-class-name "org.postgresql.Driver"}}}

现在我正在尝试为该项目设置 Travis-CI。我想在运行测试时覆盖 test 配置文件 CI 的值,因为我正在使用以下命令

lein with-profile travis 测试

这里 lein 正在激活 travis 配置文件,但它从 test 配置文件而不是 travis 配置文件中获取环境变量值。

有人遇到过这样的问题吗?

【问题讨论】:

    标签: clojure leiningen clojure.test


    【解决方案1】:

    为什么:默认为 Lein merges test profile。可以用lein with-profile travis,test pprint查看有效的工程图

    解决方案:我假设您正在使用environ 或类似的东西。如果是这样,您可以在UPCASE_WITH_UNDERSCORE(例如DATABASE_NAME=test_library_test)中使用env 导出值,它们将覆盖配置文件中的值

    【讨论】:

      猜你喜欢
      • 2019-04-11
      • 2020-08-26
      • 2021-03-21
      • 1970-01-01
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多