Soichi Takamura
Soichi Takamura

Reputation: 175

How can I configure applications only for mix-test?

Suppose we have a module A that requires a configuration. When we consume A, it's just OK to put [applications: [:a]] in mix.exs and put config :a, [] in config/config.exs in our project.

But when we're developers of the module A, how/when can we configure :a on a command of mix test in the A directory? Can we do that in test/test_helpers.exs or somewhere?

Upvotes: 0

Views: 433

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

You might want to derive the behaviour from Phoenix. What it does, is basically three additional files in config directory, named dev.exs, prod.exs and test.exs and the following clause in config.exs:

import_config "#{Mix.env}.exs"

Since mix sets the Mix.env appropriately, the respective configuration will be loaded.

Upvotes: 1

Related Questions