ext

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 5 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, 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 FakeFile

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

func NewFakeFile

func NewFakeFile(name, content string) *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, error)

func (*MockAmbassador) TempFile

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

Jump to

Keyboard shortcuts

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