mockwrite

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mockwrite writes the provided mocks to the file system.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingMockConfig = erk.New(ErkInvalidConfig{}, "Missing `mocks` config in .ensure.yml file. For example:\n\n"+ensurefile.ExampleFile)

	ErrMissingPackages = erk.New(ErkInvalidConfig{},
		"No mocks to generate. Please add some to `mocks.packages` in .ensure.yml file. For example:\n\n"+ensurefile.ExampleFile,
	)
	ErrDuplicatePackagePath = erk.New(ErkInvalidConfig{}, "Found duplicate package path: {{.packagePath}}. Package paths must be unique.")

	ErrMultipleWriteFailures = erk.New(ErkMultipleFailures{}, "Unable to write at least one mock")

	ErrUnableToCreateDir  = erk.New(ErkFSWriteError{}, "Could not create directory '{{.path}}': {{.err}}")
	ErrUnableToCreateFile = erk.New(ErkFSWriteError{}, "Could not create file '{{.path}}': {{.err}}")
)
View Source
var (
	ErrTidyUnableToList    = erk.New(ErkUnableToTidy{}, "Could not list files recursively for '{{.path}}': {{.err}}")
	ErrTidyUnableToCleanup = erk.New(ErkUnableToTidy{}, "Could not delete '{{.path}}': {{.err}}")
)
View Source
var ErrInternalPackageOutsideModule = erk.New(ErkMockDestination{},
	"Cannot generate mock of internal package, since package '{{.packagePath}}' is not in the current module '{{.modulePath}}'",
)

Functions

This section is empty.

Types

type ErkFSWriteError

type ErkFSWriteError struct{ erk.DefaultKind }

type ErkInvalidConfig

type ErkInvalidConfig struct{ erk.DefaultKind }

type ErkMockDestination

type ErkMockDestination struct{ erk.DefaultKind }

type ErkMultipleFailures

type ErkMultipleFailures struct{ erk.DefaultKind }

type ErkUnableToTidy

type ErkUnableToTidy struct{ erk.DefaultKind }

type MockWriter

type MockWriter struct {
	FSWrite fswrite.Writable
	Logger  *log.Logger
}

MockWriter writes the provided mocks to the file system.

func (*MockWriter) TidyMocks

func (w *MockWriter) TidyMocks(config *ensurefile.Config, packages []*ifacereader.Package) error

TidyMocks removes any files other than those that are expected to exist in the mock directories.

func (*MockWriter) WriteMocks

func (w *MockWriter) WriteMocks(config *ensurefile.Config, mocks []*mockgen.PackageMock) error

WriteMocks writes the provided mocks to the file system.

type Writable

type Writable interface {
	WriteMocks(config *ensurefile.Config, mocks []*mockgen.PackageMock) error
	TidyMocks(config *ensurefile.Config, packages []*ifacereader.Package) error
}

Writable writes the provided mocks to the file system.

Jump to

Keyboard shortcuts

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