Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elixir/PhoenixFramework-如何让test.secret.exs自动加载到测试环境中?_Elixir_Phoenix Framework - Fatal编程技术网

Elixir/PhoenixFramework-如何让test.secret.exs自动加载到测试环境中?

Elixir/PhoenixFramework-如何让test.secret.exs自动加载到测试环境中?,elixir,phoenix-framework,Elixir,Phoenix Framework,似乎test.secret.exs不会在test环境中自动加载 Application.get_env(:my_app,:my_settings)返回nil,即使mytest.secret.exs包含以下内容: use Mix.Config config :my_app, :my_settings, setting1: "blah", setting2: "bleh" 我正在运行Elixir 1.4.0。prod.secret.exs由prod.exs显式加载,在

似乎
test.secret.exs
不会在
test
环境中自动加载

Application.get_env(:my_app,:my_settings)
返回
nil
,即使my
test.secret.exs
包含以下内容:

use Mix.Config

config :my_app, :my_settings,
  setting1:      "blah",
  setting2:      "bleh"

我正在运行Elixir 1.4.0。

prod.secret.exs
prod.exs
显式加载,在默认Phoenix应用程序模板的末尾显示以下行:

import_config "prod.secret.exs"
默认情况下,
test.exs
没有此选项,因此如果要加载
test.secret.exs
,可以在
test.exs
末尾添加以下内容:

import_config "test.secret.exs"
import_config "#{Mix.env}.secret.exs"

除了Dogbert的答案之外,对于那些想要为每个环境加载相应的
*.secret.exs
文件的人,您可以将其放入
config/config.exs

import_config "test.secret.exs"
import_config "#{Mix.env}.secret.exs"

有了它,您可以从每个特定于环境的配置文件中删除
import\u config
函数调用。

test.exs
的末尾是否有
import\u config“test.secret.exs”
类似于
prod.exs
的函数调用?如果在
config.exs
中,我是否需要这样做
import_config“#{Mix.env}.exs”
Yes,它导入
test.exs
test.exs
应该导入
test.secret.exs
类似
prod.exs
does.Gotcha。提交答案!:)再次感谢你,狗伯特!你挽救了这一天。你就像我的长生不老药守护天使。:)