Open yiftachkarkason opened 1 month ago
I tripped up against this too, read about using the env, tried it and saw exactly what you mentioned making env variables unusable in tests.
Indeed. I want to definitively fix the config tests that depends a lot in the current state to make the tests deterministic. And, to the matter of this issue, look for a better mechanism to initialise the verbosity of the ryuk message. I think we could move that log entry to the place Ryuk is called for first time, so that the init function of that package does not interfere with the config.Read. Thoughts?
Yeah, that would be better for my use case because I'm configuring Ryuk the same for all tests. I would still consider exposing a "ReloadConfig" function to allow users to overcome such hurdles independently.
@yiftachkarkason we released v0.33.0
Could you please check with that version?
If fixed, I think we can close this one, thanks!
Testcontainers version
0.32.0
Using the latest Testcontainers version?
Yes
Host OS
MacOS
Host arch
ARM
Go version
1.22.5
Docker version
Docker info
What happened?
A recent change in version 0.32.0 introduced a
config.Read()
call in the packageinit
function, which means that the environment variables and/or properties file is read very early when the program starts.In my E2E tests, I set relevant environment variables (such as disabling Ryuk for the longer tests to avoid having the containers removed while the test is still running), and this change breaks this functionality. Currently, I can't upgrade the library past v0.31.0.
AFAICT there are 2 possible solutions:
config.Read
during the packageinit
functionconfig.Reset
function to external callers by extracting it from theinternal
directory.Thank you for you help!
Relevant log output
No response
Additional information
No response