test: fix panic on concurrent map write

This commit is contained in:
James Houlahan
2020-12-29 07:39:00 +01:00
parent 7b112fc448
commit 36a6f1ed4b
4 changed files with 27 additions and 8 deletions

View File

@ -72,10 +72,16 @@ func (ctx *TestContext) withSMTPServer() {
// SetSMTPLastResponse sets the last SMTP response that was received.
func (ctx *TestContext) SetSMTPLastResponse(handle string, resp *mocks.SMTPResponse) {
ctx.smtpResponseLocker.Lock()
defer ctx.smtpResponseLocker.Unlock()
ctx.smtpLastResponses[handle] = resp
}
// GetSMTPLastResponse returns the last IMAP response that was received.
func (ctx *TestContext) GetSMTPLastResponse(handle string) *mocks.SMTPResponse {
ctx.smtpResponseLocker.Lock()
defer ctx.smtpResponseLocker.Unlock()
return ctx.smtpLastResponses[handle]
}