Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stubber ¶ added in v1.1.0
type Stubber interface {
// Stub 会把 *originalPtr 变量替换成 fake 变量的内容。
// NOTICE: 函数在 Go 语言中,也是一种变量。
Var(originalPtr, fake interface{}) Stubber
// StubFunc 会把原先 *funcPtr 替换成另一个函数,其具有固定的返回值 returns。
Func(funcPtr interface{}, returns ...interface{}) Stubber
// StubEnv 会更改环境变量的值。
Env(key, value string) Stubber
// Restore 会把 Stubber 替换过的所有值,全部还原。
Restore()
}
Stubber 包含了打桩时所需的方法,以及恢复的方法。
func Func ¶ added in v1.1.0
func Func(funcPtr interface{}, returns ...interface{}) Stubber
Func replaces a function variable with a function that returns stubVal. funcVarToStub must be a pointer to a function variable. If the function returns multiple values, then multiple values should be passed to stubFunc. The values must match be assignable to the return values' types.
Click to show internal directories.
Click to hide internal directories.