template

package
v0.0.0-...-fd94602 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	PkgName         string
	SrcPkgQualifier string
	Imports         []*registry.Package
	Mocks           []MockData
	StubImpl        bool
	SkipEnsure      bool
	WithResets      bool
}

Data is the template data used to render the Moq template.

func (Data) MocksHaveMethod

func (d Data) MocksHaveMethod() bool

MocksHaveMethod returns true of any one of the Mocks has at least 1 method.

type MethodData

type MethodData struct {
	Name    string
	Params  []ParamData
	Returns []ParamData
}

MethodData is the data which represents a method on some interface.

func (MethodData) ArgCallList

func (m MethodData) ArgCallList() string

ArgCallList is the string representation of method call parameters, ex: 's, n, foo'. In case of a last variadic parameter, it will be of the format 's, n, foos...'.

func (MethodData) ArgList

func (m MethodData) ArgList() string

ArgList is the string representation of method parameters, ex: 's string, n int, foo bar.Baz'.

func (MethodData) ReturnArgNameList

func (m MethodData) ReturnArgNameList() string

ReturnArgNameList is the string representation of values being returned from the method, ex: 'foo', 's, err'.

func (MethodData) ReturnArgTypeList

func (m MethodData) ReturnArgTypeList() string

ReturnArgTypeList is the string representation of method return types, ex: 'bar.Baz', '(string, error)'.

type MockData

type MockData struct {
	InterfaceName string
	MockName      string
	TypeParams    []TypeParamData
	Methods       []MethodData
}

MockData is the data used to generate a mock for some interface.

type ParamData

type ParamData struct {
	Var      *registry.Var
	Variadic bool
}

ParamData is the data which represents a parameter to some method of an interface.

func (ParamData) CallName

func (p ParamData) CallName() string

CallName returns the string representation of the parameter to be used for a method call. For a variadic paramter, it will be of the format 'foos...'.

func (ParamData) MethodArg

func (p ParamData) MethodArg() string

MethodArg is the representation of the parameter in the function signature, ex: 'name a.Type'.

func (ParamData) Name

func (p ParamData) Name() string

Name returns the name of the parameter.

func (ParamData) TypeString

func (p ParamData) TypeString() string

TypeString returns the string representation of the type of the parameter.

type Template

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

Template is the Moq template. It is capable of generating the Moq implementation for the given template.Data.

func New

func New() Template

New returns a new instance of Template.

func (Template) Execute

func (t Template) Execute(w io.Writer, data Data) error

Execute generates and writes the Moq implementation for the given data.

type TypeParamData

type TypeParamData struct {
	ParamData
	Constraint types.Type
}

Jump to

Keyboard shortcuts

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