hashmail: isolate server per test

Register the Aperture instance created in setupAperture with t.Cleanup so
that every test stops its own server even if it fails. This keeps the global
HashMail stream map clean and prevents TestHashMailServerLargeMessage from
inheriting leftover streams from TestHashMailServerReturnStream.

This prevents cascading test failures, when a failure in one test is replicated
as many failures in many tests, complicating debugging from logs.
This commit is contained in:
Boris Nagaev
2025-11-26 19:47:53 -03:00
parent 92e54ece11
commit bf020ea103

View File

@@ -188,6 +188,10 @@ func setupAperture(t *testing.T) {
errChan := make(chan error)
shutdown := make(chan struct{})
require.NoError(t, aperture.Start(errChan, shutdown))
t.Cleanup(func() {
close(shutdown)
require.NoError(t, aperture.Stop())
})
// Any error while starting?
select {