Documentation ¶
Index ¶
- Variables
- type Method
- type Mock
- func (m Mock) Ast(ctx context.Context, chanSize int) []ast.Decl
- func (m Mock) Constructor(ctx context.Context, chanSize int) *ast.FuncDecl
- func (m Mock) Decl(ctx context.Context) *ast.GenDecl
- func (m Mock) Methods(ctx context.Context) (methods []Method)
- func (m Mock) Name(ctx context.Context) string
- func (m Mock) PrependLocalPackage(ctx context.Context, name string) error
- type Mocks
- type Opt
- type TypeFinder
Constants ¶
This section is empty.
Variables ¶
var ErrUnexported = errors.New("must be exported")
Functions ¶
This section is empty.
Types ¶
type Method ¶
type Method struct {
// contains filtered or unexported fields
}
Method represents a method that is being mocked.
func MethodFor ¶
MethodFor returns a Method representing typ, using receiver as the Method's receiver type and name as the method name.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock of an interface type.
func For ¶
func For(ctx context.Context, name string, params []*ast.Field, typ *ast.InterfaceType) (Mock, error)
For returns a Mock representing typ. An error will be returned if a mock cannot be created from typ.
func (Mock) Constructor ¶
Constructor returns a function AST to construct m. chanSize will be the buffer size for all channels initialized in the constructor.
type Mocks ¶
type Mocks struct {
// contains filtered or unexported fields
}
Mocks is a set of mocks generated from a go package.
func Generate ¶
Generate generates a Mocks value for all interface types that are required, according to finder.
type Opt ¶
type Opt func(genPrefs) genPrefs
Opt is an option function that can apply preferences for generating mocks.
func ForConcreteDependencies ¶
func ForConcreteDependencies() Opt
ForConcreteDependencies tells Generate to generate mocks for any interface types that are depended on by functions, methods, or struct fields in exported code.
If none of the For* options are included, the default will be to generate mocks for all strategies.
func ForLocalInterfaces ¶
func ForLocalInterfaces() Opt
ForLocalInterfaces tells Generate to generate mocks for local interface types.
If none of the For* options are included, the default will be to generate mocks for all strategies.