automock

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenerationError

type GenerationError struct {
	Err  error
	Code []byte
}

GenerationError is returned by Write when an error is encountered

func (GenerationError) CodeWithLineNumbers

func (err GenerationError) CodeWithLineNumbers() string

CodeWithLineNumbers returns all the code including line numbers

func (GenerationError) Error

func (err GenerationError) Error() string

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator produces code to mock an interface

func NewGenerator

func NewGenerator(pkg, iface string) (*Generator, error)

NewGenerator initializes a Generator that will mock the given interface from the specified package.

func (Generator) Imports

func (g Generator) Imports() map[string]string

Imports returns all the packages that have to be imported for the

func (Generator) Methods

func (g Generator) Methods() []Method

Methods returns information about all the methods required to satisfy the interface

func (Generator) Name

func (g Generator) Name() string

Name returns the mock type's name by default it is {interfaceName}Mock

func (Generator) Package

func (g Generator) Package() string

Package returns the name of the package containing the mock

func (*Generator) SetInternal

func (g *Generator) SetInternal(inPkg bool)

func (*Generator) SetName

func (g *Generator) SetName(name string)

SetName changes the mock type's name

func (*Generator) SetPackage

func (g *Generator) SetPackage(name string)

SetPackage changes the package containing the mock

func (*Generator) SetTemplate

func (g *Generator) SetTemplate(tmpl string) error

SetTemplate allows defining a different template to generate the mock. It will be parsed with text/template and execuded with the Generator.

func (Generator) Write

func (g Generator) Write(wr io.Writer) error

Write writes the generated code in the io.Writer

type Method

type Method struct {
	// contains filtered or unexported fields
}

Method contains the details from an interface method

func (Method) Name

func (m Method) Name() string

Name returns the method name

func (Method) ParamTypes

func (m Method) ParamTypes() []string

ParamTypes returns the list of types for the params

func (Method) ReturnTypes

func (m Method) ReturnTypes() []string

ReturnTypes returns the list of types for the params

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL