Use Repeatability as tie-breaker for closest match

pull/1039/head
Bo Sunesen 2019-08-28 16:13:23 +02:00 committed by Boyan Soubachov
parent 92707c0b2d
commit 1962448488
1 changed files with 3 additions and 1 deletions

View File

@ -299,6 +299,7 @@ func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *
func (m *Mock) findClosestCall(method string, arguments ...interface{}) (*Call, string) {
var diffCount int
var repeatability int
var closestCall *Call
var err string
@ -306,8 +307,9 @@ func (m *Mock) findClosestCall(method string, arguments ...interface{}) (*Call,
if call.Method == method {
errInfo, tempDiffCount := call.Arguments.Diff(arguments)
if tempDiffCount < diffCount || diffCount == 0 {
if tempDiffCount < diffCount || diffCount == 0 || (tempDiffCount == diffCount && call.Repeatability > repeatability) {
diffCount = tempDiffCount
repeatability = call.Repeatability
closestCall = call
err = errInfo
}