Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateMocks ¶
func GenerateMocks(ctx context.Context, gcfg GenerationConfiguration, mocksCfg MocksConfiguration) error
GenerateMocks generates the mocks given in arguments
Types ¶
type GenerationConfiguration ¶
type GenerationConfiguration struct {
// MocksFilePath is the path to the JSON file containing the mock configuration. Location of this file is the base package.
MocksFilePath string
// SignaturesFilename is the filename of the signatures cache. Location of this file is the base package.
SignaturesFilename string
// ConcurrentGoroutines specifies the concurrent amount of goroutines which can execute
ConcurrentGoroutines int
// NoGoMod by default we'll consider go modules is enabled, mockgen will be called with -mod=mod to read interfaces in modules instead of default GOPATH
NoGoMod bool
}
GenerationConfiguration lets you configure the generation of mocks for your project
type MockConfiguration ¶
type MockConfiguration struct {
// Interface is the name of the interface we need to generate a mock for.
Interface string `json:"interface"`
// Mockfile is the location of the generated mock file. Relative path from the root of the
// project. Defaults to a subfolder of SrcPackage ending with "mock".
MockFile string `json:"mock_file,omitempty"`
// SrcPackage is the complete name of the source package. E.g. "model/backup". Defaults to the
// directory part of Mockfile.
SrcPackage string `json:"src_package,omitempty"`
// DstPackage: name of the package of Mockfile. Defaults to the name of the folder of Mockfile.
DstPackage string `json:"dst_package,omitempty"`
// External specifies if the generated mock is about a package external to the project.
External bool `json:"external,omitempty"`
}
MockConfiguration represents a mock and how to generate it.
type MocksConfiguration ¶
type MocksConfiguration struct {
BaseDirectory string `json:"base_directory"`
// BasePackage is the project base package. E.g. github.com/Scalingo/go-utils
BasePackage string `json:"base_package"`
// Mocks contains the configuration of all the mocks to generate
Mocks []MockConfiguration `json:"mocks"`
}
MocksConfiguration contains the configuration of the mocks to generate.
Click to show internal directories.
Click to hide internal directories.