monkybrain

monkybrain

How can I reset config during runtime?

I’m writing some tests for my app and sometimes I change the runtime configs for a specific test. To make sure each test runs with the config specified in config/config.exs I’d like to “reset” the config before each test. I’ve tried adding Mix.Config.import_config("config/config.exs) to the ExUnit setup_all callback but apparently this function cannot be called during runtime (** (RuntimeError) could not set configuration via Mix.Config. This usually means you are trying to execute a configuration file directly instead of using the proper command, such as mix loadconfig). Any suggestions?

First Post!

OvermindDL1

OvermindDL1

Hmm, the config’s are immutable so I don’t see how they would be changing at run time..

Are you talking about something else like the application environment or so? If so then you could just take a snapshot of all it’s values and reset them all to that at the end of the testing run.

Most Liked

monkybrain

monkybrain

Yeah, I meant the application environment and that’s a great idea! Thanks!

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement