Merge pull request #147 from multiplay/master

Fix race condition with ExpectedCalls
pull/175/head
Ernesto Jiménez 2015-06-02 14:37:00 +01:00
commit 93a84c883d
1 changed files with 3 additions and 0 deletions

View File

@ -112,6 +112,9 @@ func (m *Mock) On(methodName string, arguments ...interface{}) *Mock {
//
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2)
func (m *Mock) Return(returnArguments ...interface{}) *Mock {
m.mutex.Lock()
defer m.mutex.Unlock()
m.ExpectedCalls = append(m.ExpectedCalls, Call{m.onMethodName, m.onMethodArguments, returnArguments, 0, nil, nil})
return m
}