Documentation ¶
Index ¶
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.
func (Method) Fields ¶
Fields returns the fields that need to be a part of the receiver struct for this method.
func (Method) PrependLocalPackage ¶
PrependLocalPackage prepends name as the package name for local types in m's signature. This is most often used when mocking types that are imported by the local package.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock of an interface type.
func For ¶
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.
func (Mock) PrependLocalPackage ¶
PrependLocalPackage prepends name as the package name for local types in m's signature. This is most often used when mocking types that are imported by the local package.
type Mocks ¶
type Mocks struct {
// contains filtered or unexported fields
}
Mocks is a set of mocks generated from a go package.
func Generate ¶
func Generate(finder TypeFinder) (*Mocks, error)
Generate generates a Mocks value for all exported interface types returned by finder.
func (*Mocks) Output ¶
Output writes the go code representing m to dest. pkg will be the package name; dir is the destination directory (needed for formatting the file); chanSize is the buffer size of any channels created in constructors.
func (*Mocks) PrependLocalPackage ¶
PrependLocalPackage prepends name as the package name for local types in m's signature. This is most often used when mocking types that are imported by the local package.
type TypeFinder ¶
type TypeFinder interface { ExportedTypes() (types []*ast.TypeSpec) Dependencies(name string) (dependencies []typ.Dependency) }
TypeFinder represents a type which knows about types and dependencies.