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
The returned container must be stopped when no longer needed using its Stop() method.
This contradicts with the documentation of Start() above. Which should I trust?
Edit2: While reading the source code, I found this:
// WithDisableAutoCleanup disables auto-removal of this container when the// tests complete. Automatic cleanup is a safety net for tests that for some// reason fail to run `gnomock.Stop()` in the end, for example due to an// unexpected `os.Exit()` somewhere.funcWithDisableAutoCleanup() Option {
returnfunc(o*Options) {
o.DisableAutoCleanup=true
}
}
Is this related?
The text was updated successfully, but these errors were encountered:
Hi @your-diary, thanks for the question and sorry for taking so long to respond.
First, it is safe to not call Stop if everything else is fine (cleaner container started up and nothing broke). I still recommend calling Stop as a best practice and a good habit of closing unused resources once they are not needed anymore.
Second, you should trust the code above the comments 😼 I might have missed some documentation changes when adding the cleaner container at some point, including changing the word most in one place, and adding information about automatic clean up in another place. Would you like to help me out and update the docs so everything becomes clear? You are correct, there is a bit of a mess.
According to the documentation of
Start()
,But it isn't clear what will happen when you don't explicitly call
gnomock.Stop()
.As far as I tested, even if I don't explicitly call
gnomock.Stop()
, a container is terminated after a test. Is this behavior guaranteed?During a test,
docker ps
shows a container for DB and unknowngnomock-cleaner
. What is this? Is there any documentation for this?Edit: I just found
Start()
internally callsStartCustom()
(source) and the documentation ofStartCustom()
says (emphasis mine):This contradicts with the documentation of
Start()
above. Which should I trust?Edit2: While reading the source code, I found this:
Is this related?
The text was updated successfully, but these errors were encountered: