Open nicolasparada opened 5 months ago
Hi, @nicolasparada! Please add usage examples of using smtpmock
here.
@mitar Do you have ideas how we can assist with it?
I think this is expected. This is another (also present before) race condition between sending and reading. Currently we do not have memory issues, but logical race condition is still present. We are just clearer about it because we do not expose any data until sending is finished. In my own tests, I also have sleep before reading .Messages
.
I think we should add an assertion to this package itself, something similar to what #154, which blocks until expected number of messages arrive, or timeout.
So something like:
.ExpectMessages(number, timeout)
which return message and error.
New bug checklist
smtpmock
to the latest versionBug description
Upgraded from
v2.2.1
tov2.3.0
and our tests started failing. Our setup is quite simple. We use it as a mock during testing. We start the mock server onTestMain()
and use it on the tests. The test consist on sending a mail using the standardnet/smtp
using the mock server address. Then reading the messages, finding the message we want and doing some assertions.We couldn't find the expected messages using
.Messages()
.I suspects there is a race condition there. Since the tests do pass locally, but they fail during CI (probably due to a slower machine on CI). I added a quick
time.Sleep(time.Millisecond)
before accessing.Messages()
and that caused the tests to pass again.