mattmartian

mattmartian

MIX_ENV=test mix test is using runtime.exs

Hi there! I’m having an issue when running MIX_ENV=test mix test. To my knowledge it should use the test.exs file which I have hardcoded values for, but when I run my tests I notice its using runtime.exs instead - is there a way to force it to use the test.exs or am I missing something? Let me know if I can provide more information

#19 [15/15] RUN MIX_ENV=test mix test
#19 sha256:83e7457056ec38a0fe7cd22e594425c37935498ebd0a3bab75d6595cc52dcf8a
#19 1.049 Compiling 8 files (.ex)
#19 1.222 Generated app
#19 1.654 ** (System.EnvError) could not fetch environment variable "QUEUE_URL" because it is not set
#19 1.654     (elixir 1.14.5) lib/system.ex:706: System.fetch_env!/1
#19 1.654     /app/config/runtime.exs:22: (file)
#19 1.654     (stdlib 4.3.1.2) erl_eval.erl:748: :erl_eval.do_apply/7
#19 1.654     (stdlib 4.3.1.2) erl_eval.erl:961: :erl_eval.expr_list/7
#19 1.654     (stdlib 4.3.1.2) erl_eval.erl:290: :erl_eval.expr/6
#19 1.654     (stdlib 4.3.1.2) erl_eval.erl:282: :erl_eval.expr/6
#19 1.654     (stdlib 4.3.1.2) erl_eval.erl:283: :erl_eval.expr/6

Marked As Solved

hubertlepicki

hubertlepicki

First off, you don’t need to specify MIX_ENV=test when you run mix test unless you’re overwriting otherwise present environemnt variable of that name.

Secondly, it’s expected behavior. runtime.exs is executed at tuntime in all environments.

If you want to limit the execution of runtime.exs in anything but prod, you can add an if clause to it like this:

import Config

if config_env() in [:prod, :staging] do
  ...
end

The above would only execute the contents of the script in :prod or :staging envs.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

We're in Beta

About us Mission Statement