Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotInterface = errors.New("expression not an interface")
ErrNotInterface is returned when the given type is not an interface type.
var ErrNotSetup = errors.New("not setup")
ErrNotSetup is returned when the generator is not configured.
Functions ¶
This section is empty.
Types ¶
type FileOutputStreamProvider ¶
type Generator ¶
Generator is responsible for generating the string containing imports and the mock struct that will later be written out as file.
func NewGenerator ¶
NewGenerator builds a Generator.
func (*Generator) Generate ¶
Generate builds a string that constitutes a valid go source file containing the mock of the relevant interface.
func (*Generator) GenerateBoilerplate ¶ added in v2.5.0
GenerateBoilerplate adds a boilerplate text. It should be called before any other generator methods to ensure the text is on top.
func (*Generator) GeneratePrologue ¶
GeneratePrologue generates the prologue of the mock.
func (*Generator) GeneratePrologueNote ¶
GeneratePrologueNote adds a note after the prologue to the output string.
type GeneratorVisitor ¶
type Interface ¶
type Interface struct { Name string // Name of the type to be mocked. QualifiedName string // Path to the package of the target type. FileName string File *ast.File Pkg *types.Package NamedType *types.Named IsFunction bool // If true, this instance represents a function, otherwise it's an interface. ActualInterface *types.Interface // Holds the actual interface type, in case it's an interface. SingleFunction *Method // Holds the function type information, in case it's a function type. }
Interface type represents the target type that we will generate a mock for. It could be an interface, or a function type. Function type emulates: an interface it has 1 method with the function signature and a general name, e.g. "Execute".
type NodeVisitor ¶
type NodeVisitor struct {
// contains filtered or unexported fields
}
func NewNodeVisitor ¶
func NewNodeVisitor() *NodeVisitor
func (*NodeVisitor) DeclaredInterfaces ¶
func (nv *NodeVisitor) DeclaredInterfaces() []string
type OutputStreamProvider ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Interfaces ¶
type StdoutStreamProvider ¶
type StdoutStreamProvider struct { }