According to the documentation of Start(),
It is recommended, but not required, to call gnomock.Stop() when the tests complete to cleanup the containers.
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 unknown gnomock-cleaner. What is this? Is there any documentation for this?
Edit: I just found Start() internally calls StartCustom() (source) and the documentation of StartCustom()says (emphasis mine):
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.
func WithDisableAutoCleanup() Option {
return func(o *Options) {
o.DisableAutoCleanup = true
}
}
Is this related?
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 psshows 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?