ext

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAmbassador = &ambassador{}
)

Functions

This section is empty.

Types

type Ambassador

type Ambassador interface {
	Environ() []string
	LookPath(string) (string, error)
	RunCmd(cmd *exec.Cmd) ([]byte, int, error)
	TempFile(dir, pattern string) (File, error)
	Remove(name string) error
}

Ambassador the ambassador to the outside "world". Wraps methods that modify global state and hence make the code that use them very hard to test.

type Clock

type Clock interface {
	Now() time.Time
}

Clock wraps the Now method. Introduced to allow replacing the global state with fixed clocks to facilitate testing. Now returns the current time.

func NewFixedClock

func NewFixedClock(fixedTime time.Time) Clock

func NewSystemClock

func NewSystemClock() Clock

type FakeFile

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

func NewFakeFile

func NewFakeFile(name string, content io.Reader) *FakeFile

NewFakeFile constructs a new FakeFile with the given name and content.

func (*FakeFile) Name

func (ff *FakeFile) Name() string

func (*FakeFile) Read

func (ff *FakeFile) Read(p []byte) (int, error)

type File

type File interface {
	Name() string
	Read([]byte) (int, error)
}

File abstracts the few methods we need, so we can test without real files.

type MockAmbassador

type MockAmbassador struct {
	mock.Mock
}

func NewMockAmbassador

func NewMockAmbassador() *MockAmbassador

func (*MockAmbassador) Environ

func (m *MockAmbassador) Environ() []string

func (*MockAmbassador) LookPath

func (m *MockAmbassador) LookPath(file string) (string, error)

func (*MockAmbassador) Remove

func (m *MockAmbassador) Remove(name string) error

func (*MockAmbassador) RunCmd

func (m *MockAmbassador) RunCmd(cmd *exec.Cmd) ([]byte, int, error)

func (*MockAmbassador) TempFile

func (m *MockAmbassador) TempFile(dir, pattern string) (file File, err error)

Jump to

Keyboard shortcuts

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