From 1962448488982378ba761489a1d48b22a8283121 Mon Sep 17 00:00:00 2001 From: Bo Sunesen Date: Wed, 28 Aug 2019 16:13:23 +0200 Subject: [PATCH] Use Repeatability as tie-breaker for closest match --- mock/mock.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mock/mock.go b/mock/mock.go index c6df4485a..4d0262153 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -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 }