Closed aisrael closed 7 years ago
Upon closer inspection, when iex -S mix
is used normally, I see
Compiling 1 file (.ex)
Generated my_app app
When MIX_ENV=test
is provided, there's no Generated my_app app
line.
So, I guess this isn't a maru
issue again, just me not understanding the tooling (mix
with MIX_ENV=test
).
Sorry, am still struggling with this. Apparently the generated my_app app
occurs whenever I do mix clean
, regardless of MIX_ENV=test
or not.
So, back to square one. I actually have a bare minimum project that exhibits this. iex -S mix
and all is well, MIX_ENV=test iex -S mix
and %Maru.Exceptions.NotFound{method: "GET", path_info: []}
, but the output of iex is identical.
test
ENV is special for maru
, you can use any ENV to run a server except test
.
Thank you chose maru
and I have stared your repo and I'll keep an eye on it!
I have so many things to do theses days, I'm sorry for the delay.
Thanks for the response @falood. Anyway I'm trying to "go deep" inside maru code itself to see if this is something I can 'hack' a solution or at least workaround for.
I noticed that in line 51 of builder.ex you do a test for the :test
configuration item, or default to Mix.env == test
.
I also noticed that maru needs to check Mix.env == test
in order for maru's unit tests themselves to pass.
So, here's what I've tried. I changed that line a bit so that it first checks if the :test
configuration key is provided. If so, then it checks if the value is true. Only if the :test
key isn't provided does it default to checking Mix.env
:
@test if (Keyword.has_key?(Application.get_all_env(:maru), :test)), do: Application.get_env(:maru, :test), else: Mix.env == :test
This allows the maru tests to proceed and pass as before.
But it also allows folks like me to go:
config :maru, MyApp.API, http: [port: p]
config :maru, test: false
To 'force' maru to ignore MIX_ENV=test
and startup 'normally'.
@falood Do you think this is acceptable? If so, I'll gladly raise a PR.
Thank you for your suggestion.
Do you think it's better to bind test
to router?
Like this:
config :maru, MyApp.API,
http: [port: 8000],
test: false
I was trying to write espec + tesla tests to exercise my maru Web service.
I'm following the guide, and so when I run
iex -S mix
then Icurl localhost:8880
, I get the expected response ({"hello":"world"}
).However, when I try to write
espec
tests or runMIX_ENV=test iex -S mix
, thencurl
reportsServer Error
. Further poking around (I replacedtext("Server Error")
withtext(inspect(e))
reveals:I'm a bit lost why MIX_ENV=test would result in such behavior.