fix: panic in integration tests

This commit is contained in:
James Houlahan 2020-07-22 12:19:52 +02:00 committed by Michal Horejsek
parent 6023162443
commit 79e6799f40
2 changed files with 7 additions and 2 deletions

View File

@ -42,7 +42,8 @@ type Controller struct {
labelsByUsername map[string][]*pmapi.Label
messagesByUsername map[string][]*pmapi.Message
log *logrus.Entry
locker sync.Locker
log *logrus.Entry
}
func NewController(cm *pmapi.ClientManager) *Controller {
@ -62,7 +63,8 @@ func NewController(cm *pmapi.ClientManager) *Controller {
labelsByUsername: map[string][]*pmapi.Label{},
messagesByUsername: map[string][]*pmapi.Message{},
log: logrus.WithField("pkg", "fakeapi-controller"),
locker: &sync.Mutex{},
log: logrus.WithField("pkg", "fakeapi-controller"),
}
cm.SetClientConstructor(func(userID string) pmapi.Client {

View File

@ -71,6 +71,9 @@ func (api *FakePMAPI) CloseConnections() {
}
func (api *FakePMAPI) checkAndRecordCall(method method, path string, request interface{}) error {
api.controller.locker.Lock()
defer api.controller.locker.Unlock()
if err := api.checkInternetAndRecordCall(method, path, request); err != nil {
return err
}