Skip to content

Commit a012e45

Browse files
Merge pull request #1636 from rainhq/jayd3e.fix_return_arguments
Record Return Arguments of a Call
2 parents 2fc4e39 + da63673 commit a012e45

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mock/mock.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ type Call struct {
8080
requires []*Call
8181
}
8282

83-
func newCall(parent *Mock, methodName string, callerInfo []string, methodArguments ...interface{}) *Call {
83+
func newCall(parent *Mock, methodName string, callerInfo []string, methodArguments Arguments, returnArguments Arguments) *Call {
8484
return &Call{
8585
Parent: parent,
8686
Method: methodName,
8787
Arguments: methodArguments,
88-
ReturnArguments: make([]interface{}, 0),
88+
ReturnArguments: returnArguments,
8989
callerInfo: callerInfo,
9090
Repeatability: 0,
9191
WaitFor: nil,
@@ -365,7 +365,8 @@ func (m *Mock) On(methodName string, arguments ...interface{}) *Call {
365365

366366
m.mutex.Lock()
367367
defer m.mutex.Unlock()
368-
c := newCall(m, methodName, assert.CallerInfo(), arguments...)
368+
369+
c := newCall(m, methodName, assert.CallerInfo(), arguments, make([]interface{}, 0))
369370
m.ExpectedCalls = append(m.ExpectedCalls, c)
370371
return c
371372
}
@@ -544,7 +545,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen
544545
call.totalCalls++
545546

546547
// add the call
547-
m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments...))
548+
m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments, call.ReturnArguments))
548549
m.mutex.Unlock()
549550

550551
// block if specified

0 commit comments

Comments
 (0)