forked from Silverfish/proton-bridge
fix: panic in integration tests
This commit is contained in:
committed by
Michal Horejsek
parent
6023162443
commit
79e6799f40
@ -42,7 +42,8 @@ type Controller struct {
|
|||||||
labelsByUsername map[string][]*pmapi.Label
|
labelsByUsername map[string][]*pmapi.Label
|
||||||
messagesByUsername map[string][]*pmapi.Message
|
messagesByUsername map[string][]*pmapi.Message
|
||||||
|
|
||||||
log *logrus.Entry
|
locker sync.Locker
|
||||||
|
log *logrus.Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewController(cm *pmapi.ClientManager) *Controller {
|
func NewController(cm *pmapi.ClientManager) *Controller {
|
||||||
@ -62,7 +63,8 @@ func NewController(cm *pmapi.ClientManager) *Controller {
|
|||||||
labelsByUsername: map[string][]*pmapi.Label{},
|
labelsByUsername: map[string][]*pmapi.Label{},
|
||||||
messagesByUsername: map[string][]*pmapi.Message{},
|
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 {
|
cm.SetClientConstructor(func(userID string) pmapi.Client {
|
||||||
|
|||||||
@ -71,6 +71,9 @@ func (api *FakePMAPI) CloseConnections() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (api *FakePMAPI) checkAndRecordCall(method method, path string, request interface{}) error {
|
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 {
|
if err := api.checkInternetAndRecordCall(method, path, request); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user