Documentation ¶
Overview ¶
Package stub provides helper functions to replace global variables for testing, and restore them afterwards.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Func ¶
Func replaces the value of a function pointer with a function that returns the provided values. It returns a function that restores the original function. If the function has multiple return values, pass them all.
Idiomatic usage will look like this:
func TestSomething(t *testing.T) { defer stub.StubFunc(&globalFunc, 42)() globalFunc() // returns 42 // ... }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.