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

@ -71,10 +71,16 @@ func (ctx *TestContext) withIMAPServer() {
// SetIMAPLastResponse sets the last IMAP response that was received.
func (ctx *TestContext) SetIMAPLastResponse(handle string, resp *mocks.IMAPResponse) {
ctx.imapResponseLocker.Lock()
defer ctx.imapResponseLocker.Unlock()
ctx.imapLastResponses[handle] = resp
}
// GetIMAPLastResponse returns the last IMAP response that was received.
func (ctx *TestContext) GetIMAPLastResponse(handle string) *mocks.IMAPResponse {
ctx.imapResponseLocker.Lock()
defer ctx.imapResponseLocker.Unlock()
return ctx.imapLastResponses[handle]
}