-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Race condition detected when run in test files #124
Comments
@benjamin-rood Hello! Good catch 👍 Thanks for your report. Seems like it an urgent issue, I'll take a look as soon as possible. I will be grateful for suggestions. |
Thanks for your prompt acknowledgement, Vladislav. Yes, it's very urgent, I think!
To begin with, can you tell me: Am I doing it the correct way, by creating a mock server instance in Secondly, is this the first time you have encountered any reports of race conditions? The only possible issue I can notice on the caller side—i.e. my code, |
Just cloned this repo and ran the tests with the
Full verbose output:
|
I've played with the code and seemingly fixed the race conditions, at least as they occur in the repo's own tests. Will push it soon as a PR where we can discuss the approach. |
PR: #125 |
@benjamin-rood First of all, thanks for your intention to improve
The main idea of using was start iteration with server instance (with predefined behaviour) during tests and terminate after: server := smtpmock.New(smtpmock.ConfigurationAttr{})
server.Start()
hostAddress, portNumber := "127.0.0.1", server.PortNumber
connection, _ := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", hostAddress, portNumber), time.Duration(2) * time.Second)
client, _ := smtp.NewClient(connection, hostAddress)
client.Hello("example.com")
client.Quit()
client.Close()
// Each result of SMTP session will be saved as message.
// To get access to server messages use Messages() method
server.Messages()
server.Stop()
Yeah, your report has been the first. I am ashamed 😟, but I forgot to add the task about passing tests with a race flag to the backlog.
Awesome, thanks 👍 I'll review it. |
" I am ashamed 😟" - Never, don't be. |
Thank you, Mark! |
@dandare100, @benjamin-rood Already in latest ( |
Fantastic turnaround time! 😎👏👏👏👏
… Message ID: ***@***.***>
|
I'm really appreciate your intention, report with extended comments and PR to get |
New bug checklist
smtpmock
to the latest versionBug description
Race condition detected when running tests in file
Test file:
Complete output when running smtpmock, including the stack trace and command used
The text was updated successfully, but these errors were encountered: