gen

package
v0.0.0-...-4921599 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWriter

type FileWriter struct{}

FileWriter creates normal files on disk.

func (FileWriter) Write

func (FileWriter) Write(path, source string) error

Write creates/truncates a file at path and writes source to it.

type PackagePlacer

type PackagePlacer struct {
	FilePerInterface bool
}

PackagePlacer puts mocks into the same package as their interfaces, either in a single file (if FilePerInterface is false) or one mock per file (if true).

Without FilePerInterface: the mock of foo.Bar is placed in foo/mocks.go With FilePerInterface: the mock of foo.Bar is placed in foo/mock_bar.go

func (PackagePlacer) Place

func (pp PackagePlacer) Place(path string, intf *parse.Interface) string

Place decides on the filename and directory that an interface's mock should be written to.

type Placer

type Placer interface {
	Place(path string, intf *parse.Interface) string
}

Placer decides where to write the source code for an interface's mock.

type Renderer

type Renderer interface {
	Render(*parse.Package, []parse.Interface) (string, error)
}

Renderer generates the complete contents of a Go source file, including imports, that defines mocks and/or stubs for a number of interfaces.

func NewGomutiRenderer

func NewGomutiRenderer() Renderer

NewGomutiRenderer creates a code generator using github.com/xeger/gomuti. The mock type contains a gomuti.Mock and can be programmed using the gomuti.Allow() method.

func NewTestifyRenderer

func NewTestifyRenderer() Renderer

NewTestifyRenderer creates a code generator for github.com/stretchr/testify. The mock type embeds tesify/mock.Mock and can be programmed using the embedded methods.

type StdoutWriter

type StdoutWriter struct{}

StdoutWriter prints file contents to the screen.

func (StdoutWriter) Write

func (StdoutWriter) Write(path, source string) error

Write prints source to the screen.

type Writer

type Writer interface {
	Write(path, source string) error
}

Writer can write source to specified absolute file paths.

Jump to

Keyboard shortcuts

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