[VOL-4291] Rw-core updates for gRPC migration
Change-Id: I8d5a554409115b29318089671ca4e1ab3fa98810
diff --git a/vendor/github.com/golang/mock/gomock/call.go b/vendor/github.com/golang/mock/gomock/call.go
index b18cc2d..13c9f44 100644
--- a/vendor/github.com/golang/mock/gomock/call.go
+++ b/vendor/github.com/golang/mock/gomock/call.go
@@ -50,16 +50,16 @@
t.Helper()
// TODO: check arity, types.
- margs := make([]Matcher, len(args))
+ mArgs := make([]Matcher, len(args))
for i, arg := range args {
if m, ok := arg.(Matcher); ok {
- margs[i] = m
+ mArgs[i] = m
} else if arg == nil {
// Handle nil specially so that passing a nil interface value
// will match the typed nils of concrete args.
- margs[i] = Nil()
+ mArgs[i] = Nil()
} else {
- margs[i] = Eq(arg)
+ mArgs[i] = Eq(arg)
}
}
@@ -76,7 +76,7 @@
return rets
}}
return &Call{t: t, receiver: receiver, method: method, methodType: methodType,
- args: margs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions}
+ args: mArgs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions}
}
// AnyTimes allows the expectation to be called 0 or more times
@@ -113,19 +113,25 @@
v := reflect.ValueOf(f)
c.addAction(func(args []interface{}) []interface{} {
- vargs := make([]reflect.Value, len(args))
+ c.t.Helper()
+ vArgs := make([]reflect.Value, len(args))
ft := v.Type()
+ if c.methodType.NumIn() != ft.NumIn() {
+ c.t.Fatalf("wrong number of arguments in DoAndReturn func for %T.%v: got %d, want %d [%s]",
+ c.receiver, c.method, ft.NumIn(), c.methodType.NumIn(), c.origin)
+ return nil
+ }
for i := 0; i < len(args); i++ {
if args[i] != nil {
- vargs[i] = reflect.ValueOf(args[i])
+ vArgs[i] = reflect.ValueOf(args[i])
} else {
// Use the zero value for the arg.
- vargs[i] = reflect.Zero(ft.In(i))
+ vArgs[i] = reflect.Zero(ft.In(i))
}
}
- vrets := v.Call(vargs)
- rets := make([]interface{}, len(vrets))
- for i, ret := range vrets {
+ vRets := v.Call(vArgs)
+ rets := make([]interface{}, len(vRets))
+ for i, ret := range vRets {
rets[i] = ret.Interface()
}
return rets
@@ -142,17 +148,23 @@
v := reflect.ValueOf(f)
c.addAction(func(args []interface{}) []interface{} {
- vargs := make([]reflect.Value, len(args))
+ c.t.Helper()
+ if c.methodType.NumIn() != v.Type().NumIn() {
+ c.t.Fatalf("wrong number of arguments in Do func for %T.%v: got %d, want %d [%s]",
+ c.receiver, c.method, v.Type().NumIn(), c.methodType.NumIn(), c.origin)
+ return nil
+ }
+ vArgs := make([]reflect.Value, len(args))
ft := v.Type()
for i := 0; i < len(args); i++ {
if args[i] != nil {
- vargs[i] = reflect.ValueOf(args[i])
+ vArgs[i] = reflect.ValueOf(args[i])
} else {
// Use the zero value for the arg.
- vargs[i] = reflect.Zero(ft.In(i))
+ vArgs[i] = reflect.Zero(ft.In(i))
}
}
- v.Call(vargs)
+ v.Call(vArgs)
return nil
})
return c
@@ -353,12 +365,12 @@
// matches all the remaining arguments or the lack of any.
// Convert the remaining arguments, if any, into a slice of the
// expected type.
- vargsType := c.methodType.In(c.methodType.NumIn() - 1)
- vargs := reflect.MakeSlice(vargsType, 0, len(args)-i)
+ vArgsType := c.methodType.In(c.methodType.NumIn() - 1)
+ vArgs := reflect.MakeSlice(vArgsType, 0, len(args)-i)
for _, arg := range args[i:] {
- vargs = reflect.Append(vargs, reflect.ValueOf(arg))
+ vArgs = reflect.Append(vArgs, reflect.ValueOf(arg))
}
- if m.Matches(vargs.Interface()) {
+ if m.Matches(vArgs.Interface()) {
// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, gomock.Any())
// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, someSliceMatcher)
// Got Foo(a, b) want Foo(matcherA, matcherB, gomock.Any())
@@ -380,7 +392,7 @@
// Check that all prerequisite calls have been satisfied.
for _, preReqCall := range c.preReqs {
if !preReqCall.satisfied() {
- return fmt.Errorf("Expected call at %s doesn't have a prerequisite call satisfied:\n%v\nshould be called before:\n%v",
+ return fmt.Errorf("expected call at %s doesn't have a prerequisite call satisfied:\n%v\nshould be called before:\n%v",
c.origin, preReqCall, c)
}
}
@@ -425,7 +437,7 @@
}
func formatGottenArg(m Matcher, arg interface{}) string {
- got := fmt.Sprintf("%v", arg)
+ got := fmt.Sprintf("%v (%T)", arg, arg)
if gs, ok := m.(GotFormatter); ok {
got = gs.Got(arg)
}