Documentation
¶
Overview ¶
Package mock provides a code generator to generate mocks using the "github.com/stretchr/testify/mock" package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GenSpecification ¶
type GenSpecification struct {
// the interface to generate a mock for
I parse.Interface
// module the interface belongs to, can be used to determine package names and file paths
Module parse.Module
// Package the file will be created in.
// Path must be relative to the module, e.g. if the module is "example.com/abc" and the package is "example.com/abc/xyz/def" use "xyz/def".
// If empty use the same package as the interface.
Package string `json:"package"`
// Filename of the output, defaults to "mock.go".
Output string `json:"output"`
}
GenSpecification defines the input data and configuration for MockGenerator.
func SpecFromAnnotations ¶
func SpecFromAnnotations(i parse.Interface, m parse.Module, a annotations.InterfaceAnnotation) (GenSpecification, error)
func (GenSpecification) PackageName ¶
func (g GenSpecification) PackageName() string
The package name to use in a source file, the last element of the full package path. E.g. for the package "example.com/abc/xyz" the package name would be "xyz".
type MockGenerator ¶
type MockGenerator struct {
Spec GenSpecification
// contains filtered or unexported fields
}
func NewMockGenerator ¶
func NewMockGenerator(spec GenSpecification) *MockGenerator
Click to show internal directories.
Click to hide internal directories.