Documentation
¶
Overview ¶
Package mock provides a simple way to stub struct methods.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Any = struct{}{}
Any input
Functions ¶
func Proxy ¶
func Proxy[M any](mock Fallbackable, method M) M
Proxy the input and output of method on mock for later stub.
Types ¶
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock helper for interface stubbing
type StubOn ¶
type StubOn struct {
// contains filtered or unexported fields
}
StubOn utils
func On ¶
func On[M any](mock Fallbackable, method M) *StubOn
On helper to stub methods to conditionally return values.
type StubReturn ¶
type StubReturn struct {
// contains filtered or unexported fields
}
StubReturn utils
func (*StubReturn) Once ¶
func (s *StubReturn) Once() *StubOn
Once specifies stubs only once before stop
func (*StubReturn) Times ¶
func (s *StubReturn) Times(n int) *StubOn
Times specifies how how many stubs before stop, if n <= 0 it will never stop.
type StubTimes ¶
type StubTimes struct {
// contains filtered or unexported fields
}
StubTimes utils
type StubWhen ¶
type StubWhen struct {
// contains filtered or unexported fields
}
StubWhen utils
func (*StubWhen) Return ¶
func (s *StubWhen) Return(out ...interface{}) *StubReturn
Return the out as the return values of stubbed method
Click to show internal directories.
Click to hide internal directories.