You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had some test failures in my buffalo app that I traced back to the following problem: I was running go test ./actions/ manually rather than using buffalo test. GO_ENV was being automatically set to development inside my app, rather than test, causing a lot of confusion.
It looks like envy tries to detect the presence of the golang test environment, and if present, sets GO_ENV to test if otherwise undefined.
However this only works if the testing package has already been loaded by go before envy's init() func gets run. I don't think we can count on the order of package initialization if there is no explicit dependency between them. I've created a gist that demonstrates this.
In my own non-buffalo projects I have run into this general problem of how to detect when running in a unit test and setting the environment appropriately. I haven't come up with a good solution.
The text was updated successfully, but these errors were encountered:
armhold
added a commit
to armhold/envy
that referenced
this issue
Oct 11, 2018
I had some test failures in my buffalo app that I traced back to the following problem: I was running
go test ./actions/
manually rather than usingbuffalo test
.GO_ENV
was being automatically set todevelopment
inside my app, rather thantest
, causing a lot of confusion.It looks like envy tries to detect the presence of the golang test environment, and if present, sets
GO_ENV
totest
if otherwise undefined.However this only works if the testing package has already been loaded by go before envy's
init()
func gets run. I don't think we can count on the order of package initialization if there is no explicit dependency between them. I've created a gist that demonstrates this.In my own non-buffalo projects I have run into this general problem of how to detect when running in a unit test and setting the environment appropriately. I haven't come up with a good solution.
The text was updated successfully, but these errors were encountered: