libmockery

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2020 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "v3"
)

Variables

View Source
var ErrNotInterface = errors.New("expression not an interface")

ErrNotInterface is returned when the given type is not an interface type.

View Source
var ErrNotSetup = errors.New("not setup")

ErrNotSetup is returned when the generator is not configured.

View Source
var Gopath = os.Getenv("GOPATH")

Functions

func Same

func Same(a, b Content) error

Types

type Cleanup

type Cleanup func() error

type Content

type Content map[string]string

type FileOutputStreamProvider

type FileOutputStreamProvider struct {
	BaseDir string
}

func (*FileOutputStreamProvider) GetWriter

func (fosp *FileOutputStreamProvider) GetWriter(iface *Interface) (io.Writer, error, Cleanup)

type Generator

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

Generator is responsible for generating the string containing imports and the mock struct that will later be written out as file.

func NewGenerator

func NewGenerator(iface *Interface, pkg string) *Generator

NewGenerator builds a Generator.

func (*Generator) Generate

func (g *Generator) Generate() error

Generate builds a string that constitutes a valid go source file containing the mock of the relevant interface.

func (*Generator) GeneratePrologue

func (g *Generator) GeneratePrologue(pkg string)

GeneratePrologue generates the prologue of the mock.

func (*Generator) GeneratePrologueComment

func (g *Generator) GeneratePrologueComment(note string)

GeneratePrologueComment adds a note after the prologue to the output string.

func (*Generator) Write

func (g *Generator) Write(w io.Writer) error

type GeneratorVisitor

type GeneratorVisitor struct {
	Comment           string
	OutputPackageName string
	OutputProvider    OutputStreamProvider
}

func (*GeneratorVisitor) VisitWalk

func (gv *GeneratorVisitor) VisitWalk(iface *Interface) error

type Hasher

type Hasher interface {
	Hash() (Content, error)
}

func NewHasher

func NewHasher(root string) Hasher

type Interface

type Interface struct {
	Name string
	// Path      string
	Type      *types.Interface
	NamedType *types.Named
}

type OutputStreamProvider

type OutputStreamProvider interface {
	GetWriter(iface *Interface) (io.Writer, error, Cleanup)
}

type Parser

type Parser interface {
	Parse(path string) error
	Load() error
	Find(name string) (*Interface, error)
	FindInPackage(name string, pkg *types.Package) *Interface
	Interfaces() []*Interface
}

type Parser2

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

func NewParser2

func NewParser2(verbose bool) *Parser2

func (*Parser2) Find

func (p *Parser2) Find(path string) (*Interface, error)

func (*Parser2) FindInPackage

func (p *Parser2) FindInPackage(name string, pkg *types.Package) *Interface

func (*Parser2) Interfaces

func (p *Parser2) Interfaces() []*Interface

func (*Parser2) Load

func (p *Parser2) Load() error

func (*Parser2) Parse

func (p *Parser2) Parse(filename string) error

type StdoutStreamProvider

type StdoutStreamProvider struct {
}

func (*StdoutStreamProvider) GetWriter

func (ssp *StdoutStreamProvider) GetWriter(iface *Interface) (io.Writer, error, Cleanup)

type Walker

type Walker struct {
	Verbose   bool
	BaseDir   string
	Interface string
}

func (*Walker) Walk

func (w *Walker) Walk(visitor WalkerVisitor) bool

Walk returns true if a mock is generated.

type WalkerVisitor

type WalkerVisitor interface {
	VisitWalk(*Interface) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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