Documentation ¶
Index ¶
- Variables
- func CallOld()
- func Mock(fn interface{}, interceptor Interceptor) func()
- func MockByName(pkgPath string, funcName string, interceptor Interceptor) func()
- func MockMethodByName(instance interface{}, method string, interceptor Interceptor) func()
- func Patch(fn interface{}, replacer interface{}) func()
- func PatchByName(pkgPath string, funcName string, replacer interface{}) func()
- func PatchMethodByName(instance interface{}, method string, replacer interface{}) func()
- type Interceptor
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCallOld = errors.New("mock: call old")
a marker to indicate the original function should be called
Functions ¶
func Mock ¶
func Mock(fn interface{}, interceptor Interceptor) func()
Mock setup mock on given function `fn`. `fn` can be a function or a method, if `fn` is a method, only the bound instance will be mocked, other instances are not affected. The returned function can be used to cancel the passed interceptor.
func MockByName ¶
func MockByName(pkgPath string, funcName string, interceptor Interceptor) func()
func MockMethodByName ¶
func MockMethodByName(instance interface{}, method string, interceptor Interceptor) func()
Can instance be nil?
func Patch ¶
func Patch(fn interface{}, replacer interface{}) func()
Patch replaces `fn` with `replacer` in current goroutine, it returns a cleanup function to remove `replacer`. the `replacer` will be automatically cleared when current gorotuine exits if the returned cleanup function is not called.
func PatchByName ¶
func PatchMethodByName ¶
func PatchMethodByName(instance interface{}, method string, replacer interface{}) func()
Types ¶
Click to show internal directories.
Click to hide internal directories.