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{})
| 473 | // appropriate .On .Return() calls) |
| 474 | // If Call.WaitFor is set, blocks until the channel is closed or receives a message. |
| 475 | func (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 |