I have a test that reads Auth Code from mailbox and uses it to log in. I use Gmail API for that.
I would like to have several such tests that will run in parallel.
However, I don't know, how to distinguish emails from each other, because the only thing that is different about 2 emails is this Auth Code.
So, race condition looks like this:
- test-1 sends an email at 00:00:00
- test-2 sends an email at 00:00:01
- it takes 3 seconds for the email-1 to arrive => 00:00:03,
- it takes only 1 second for the email-2 to arrive => 00:00:02
- test-1 reads the first unread matching email, and it is an email-2 Result: Auth code is wrong.
So, my question here is: could you please think of any possible solution to avoid such a race condition and identify the email?