update testing related dependencies

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2021-05-18 19:31:47 -04:00
parent 22ec3b0edd
commit 0803ea49b9
155 changed files with 2892 additions and 3215 deletions

View File

@@ -297,25 +297,52 @@ func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *
return -1, expectedCall
}
type matchCandidate struct {
call *Call
mismatch string
diffCount int
}
func (c matchCandidate) isBetterMatchThan(other matchCandidate) bool {
if c.call == nil {
return false
}
if other.call == nil {
return true
}
if c.diffCount > other.diffCount {
return false
}
if c.diffCount < other.diffCount {
return true
}
if c.call.Repeatability > 0 && other.call.Repeatability <= 0 {
return true
}
return false
}
func (m *Mock) findClosestCall(method string, arguments ...interface{}) (*Call, string) {
var diffCount int
var closestCall *Call
var err string
var bestMatch matchCandidate
for _, call := range m.expectedCalls() {
if call.Method == method {
errInfo, tempDiffCount := call.Arguments.Diff(arguments)
if tempDiffCount < diffCount || diffCount == 0 {
diffCount = tempDiffCount
closestCall = call
err = errInfo
tempCandidate := matchCandidate{
call: call,
mismatch: errInfo,
diffCount: tempDiffCount,
}
if tempCandidate.isBetterMatchThan(bestMatch) {
bestMatch = tempCandidate
}
}
}
return closestCall, err
return bestMatch.call, bestMatch.mismatch
}
func callString(method string, arguments Arguments, includeArgumentValues bool) string {