John
John

Reputation: 9456

Elixir/PhoenixFramework - How do I get test.secret.exs to automatically load in test environment?

It seems as though test.secret.exs does not load up automatically in the test environment.

Application.get_env(:my_app, :my_settings) returns nil even though my test.secret.exs contains the following:

use Mix.Config

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

I'm running Elixir 1.4.0.

Upvotes: 0

Views: 434

Answers (2)

John
John

Reputation: 9456

In addition to Dogbert's answer, for those who want a DRY solution for loading the respective *.secret.exs file for each environment, you can put this into config/config.exs:

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

With that in there, you can remove the import_config function call from each environment-specific config file.

Upvotes: 0

Dogbert
Dogbert

Reputation: 222388

prod.secret.exs is explicitly loaded by prod.exs with this line present at the end in the default Phoenix app template:

import_config "prod.secret.exs"

test.exs does not have this by default, so if you want to load test.secret.exs, you can add the following at the end of test.exs:

import_config "test.secret.exs"

Upvotes: 1

Related Questions