mock

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 7 Imported by: 0

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 (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

func (*MockGenerator) Generate

func (m *MockGenerator) Generate() (result []gen.GenResult, err error)

Jump to

Keyboard shortcuts

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