Documentation ¶
Index ¶
- Variables
- func RegisterCommand(name string, cmd Command)
- func Usage(w io.Writer)
- type Command
- type CommandLineError
- type Func
- func (f *Func) IsMethod() bool
- func (f *Func) IsVariadic() bool
- func (f *Func) LastParam() *ast.Field
- func (f *Func) LastResult() *ast.Field
- func (f *Func) Name() string
- func (f *Func) NumParams() int
- func (f *Func) NumResults() int
- func (f *Func) Params(fs *token.FileSet) []string
- func (f *Func) ParamsNames() []string
- func (f *Func) ReceiverType() ast.Expr
- func (f *Func) Results(fs *token.FileSet) []string
- func (f *Func) ResultsNames() []string
- func (f *Func) ReturnsError() bool
- func (f *Func) TestName() string
- type Generator
- type GenericError
- type Options
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( ErrGenerateHeader = GenericError("failed to write header: %v") ErrGenerateTest = GenericError("failed to write test: %v") ErrFuncNotFound = GenericError("unable to find a function declaration") ErrFailedToParseInFile = GenericError("failed to parse input file: %v") ErrFailedToParseOutFile = GenericError("failed to parse output file: %v") ErrFailedToOpenInFile = GenericError("failed to open input file: %v") ErrFailedToOpenOutFile = GenericError("failed to open output file: %v") ErrFailedToCreateOutFile = GenericError("failed to create output file: %v") ErrInputFileDoesNotExist = GenericError("input file does not exist") ErrSeekFailed = GenericError("failed to seek: %v") ErrFixImports = GenericError("failed to fix imports: %v") ErrWriteTest = GenericError("failed to write generated test: %v") ErrInvalidTestTemplate = GenericError("invalid test template: %v") )
Functions ¶
func RegisterCommand ¶
Types ¶
type Command ¶
type Command interface { //FlagSet returns command specific flag set. If command doesn't have any flags nil should be returned. FlagSet() *flag.FlagSet //Run runs command Run(args []string, stdout, stderr io.Writer) error //Description returns short description of a command that is shown in the help message Description() string //Usage line Usage() string }
func GetCommand ¶
type CommandLineError ¶
type CommandLineError string
func (CommandLineError) Error ¶
func (e CommandLineError) Error() string
type Func ¶
Func is a wrapper around ast.FuncDecl containing few methods to use within a test template
func (*Func) IsVariadic ¶
IsVariadic returns true if it's the variadic function
func (*Func) LastResult ¶
LastResult returns function's last result
func (*Func) NumResults ¶
NumResults returns a number of the function results
func (*Func) ParamsNames ¶
ParamsNames returns a list of the function params' names
func (*Func) ReceiverType ¶
ReceiverType returns a type of the method receiver
func (*Func) Results ¶
Results returns a list of the function results with their types if function's last param is an error it is not included in the result slice
func (*Func) ResultsNames ¶
ResultsNames returns a list of the function results' names if function's last result is an error the name of param is "err"
func (*Func) ReturnsError ¶
ReturnsError returns true if the function's last param's type is error
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is used to generate a test stub for function Func
func NewGenerator ¶
NewGenerator returns a pointer to Generator
func (*Generator) WriteHeader ¶
WriteHeader writes a package name and import specs
type GenericError ¶
type GenericError string
func (GenericError) Error ¶
func (e GenericError) Error() string
func (GenericError) Format ¶
func (e GenericError) Format(args ...interface{}) GenericError
type Request ¶
type Request struct { InputFilePath string `json:"inputFilePath"` OutputFilePath string `json:"outputFilePath"` InputFile string `json:"inputFile"` OutputFile string `json:"outputFile"` TemplateName string `json:"templateName"` Comment string `json:"comment"` Lines []int `json:"lines"` }
Request is a JSON object that is read from Stdin in JSON mode (see -json command line flag)