MCPcopy
hub / github.com/stretchr/testify / Called

Method Called

mock/mock.go:475–492  ·  view source on GitHub ↗

Called tells the mock object that a method has been called, and gets an array of arguments to return. Panics if the call is unexpected (i.e. not preceded by appropriate .On .Return() calls) If Call.WaitFor is set, blocks until the channel is closed or receives a message.

(arguments ...interface{})

Source from the content-addressed store, hash-verified

473// appropriate .On .Return() calls)
474// If Call.WaitFor is set, blocks until the channel is closed or receives a message.
475func (m *Mock) Called(arguments ...interface{}) Arguments {
476 // get the calling function's name
477 pc, _, _, ok := runtime.Caller(1)
478 if !ok {
479 panic("Couldn't get the caller information")
480 }
481 functionPath := runtime.FuncForPC(pc).Name()
482 // Next four lines are required to use GCCGO function naming conventions.
483 // For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
484 // uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
485 // With GCCGO we need to remove interface information starting from pN<dd>.
486 if gccgoRE.MatchString(functionPath) {
487 functionPath = gccgoRE.Split(functionPath, -1)[0]
488 }
489 parts := strings.Split(functionPath, ".")
490 functionName := parts[len(parts)-1]
491 return m.MethodCalled(functionName, arguments...)
492}
493
494// MethodCalled tells the mock object that the given method has been called, and gets
495// an array of arguments to return. Panics if the call is unexpected (i.e. not preceded

Callers 15

RoundTripMethod · 0.80
TheExampleMethodMethod · 0.80
TheExampleMethod2Method · 0.80
TheExampleMethod3Method · 0.80
TheExampleMethod4Method · 0.80
TheExampleMethod5Method · 0.80
TheExampleMethod6Method · 0.80
TheExampleMethod7Method · 0.80
TheExampleMethodFuncMethod · 0.80

Calls 2

MethodCalledMethod · 0.95
NameMethod · 0.65

Tested by 15

TheExampleMethodMethod · 0.64
TheExampleMethod2Method · 0.64
TheExampleMethod3Method · 0.64
TheExampleMethod4Method · 0.64
TheExampleMethod5Method · 0.64
TheExampleMethod6Method · 0.64
TheExampleMethod7Method · 0.64
TheExampleMethodFuncMethod · 0.64