fakes

package
v0.0.418 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 15 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeCmdCallback

type FakeCmdCallback func()

type FakeCmdResult

type FakeCmdResult struct {
	Stdout     string
	Stderr     string
	ExitStatus int
	Error      error

	Sticky bool // Set to true if this result should ALWAYS be returned for the given command
}

type FakeCmdRunner

type FakeCmdRunner struct {
	RunComplexCommands   []boshsys.Command
	RunCommands          [][]string
	RunCommandsWithInput [][]string
	RunCommandsQuietly   [][]string

	CommandExistsValue bool
	AvailableCommands  map[string]bool
	// contains filtered or unexported fields
}

func NewFakeCmdRunner

func NewFakeCmdRunner() *FakeCmdRunner

func (*FakeCmdRunner) AddCmdResult

func (r *FakeCmdRunner) AddCmdResult(fullCmd string, result FakeCmdResult)

func (*FakeCmdRunner) AddProcess

func (r *FakeCmdRunner) AddProcess(fullCmd string, process *FakeProcess)

func (*FakeCmdRunner) ClearCommandHistory

func (r *FakeCmdRunner) ClearCommandHistory()

func (*FakeCmdRunner) CommandExists

func (r *FakeCmdRunner) CommandExists(cmdName string) bool

func (*FakeCmdRunner) RunCommand

func (r *FakeCmdRunner) RunCommand(cmdName string, args ...string) (string, string, int, error)

func (*FakeCmdRunner) RunCommandQuietly

func (r *FakeCmdRunner) RunCommandQuietly(cmdName string, args ...string) (string, string, int, error)

func (*FakeCmdRunner) RunCommandWithInput

func (r *FakeCmdRunner) RunCommandWithInput(input, cmdName string, args ...string) (string, string, int, error)

func (*FakeCmdRunner) RunComplexCommand

func (r *FakeCmdRunner) RunComplexCommand(cmd boshsys.Command) (string, string, int, error)

func (*FakeCmdRunner) RunComplexCommandAsync

func (r *FakeCmdRunner) RunComplexCommandAsync(cmd boshsys.Command) (boshsys.Process, error)

func (*FakeCmdRunner) SetCmdCallback

func (r *FakeCmdRunner) SetCmdCallback(fullCmd string, callback FakeCmdCallback)

type FakeFile

type FakeFile struct {
	Stats *FakeFileStats

	WriteErr error
	Contents []byte

	ReadErr   error
	ReadAtErr error

	CloseErr error

	StatErr error
	// contains filtered or unexported fields
}

func NewFakeFile

func NewFakeFile(path string, fs *FakeFileSystem) *FakeFile

func (*FakeFile) Close

func (f *FakeFile) Close() error

func (*FakeFile) Name

func (f *FakeFile) Name() string

func (*FakeFile) Read

func (f *FakeFile) Read(b []byte) (int, error)

func (*FakeFile) ReadAt

func (f *FakeFile) ReadAt(b []byte, offset int64) (int, error)

func (*FakeFile) Seek

func (f *FakeFile) Seek(offset int64, whence int) (int64, error)

func (FakeFile) Stat

func (f FakeFile) Stat() (os.FileInfo, error)

func (*FakeFile) Write

func (f *FakeFile) Write(contents []byte) (int, error)

func (*FakeFile) WriteAt

func (f *FakeFile) WriteAt(b []byte, offset int64) (int, error)

type FakeFileInfo

type FakeFileInfo struct {
	os.FileInfo
	// contains filtered or unexported fields
}

func (FakeFileInfo) IsDir

func (fi FakeFileInfo) IsDir() bool

func (FakeFileInfo) ModTime

func (fi FakeFileInfo) ModTime() time.Time

func (FakeFileInfo) Mode

func (fi FakeFileInfo) Mode() os.FileMode

func (FakeFileInfo) Size

func (fi FakeFileInfo) Size() int64

type FakeFileRegistry

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

func NewFakeFileRegistry

func NewFakeFileRegistry() *FakeFileRegistry

func (*FakeFileRegistry) Get

func (ffr *FakeFileRegistry) Get(path string) *FakeFile

func (*FakeFileRegistry) Register

func (ffr *FakeFileRegistry) Register(path string, file *FakeFile)

func (*FakeFileRegistry) Remove

func (ffr *FakeFileRegistry) Remove(path string)

func (*FakeFileRegistry) UnifiedPath

func (ffr *FakeFileRegistry) UnifiedPath(path string) string

type FakeFileStats

type FakeFileStats struct {
	FileType FakeFileType

	FileMode  os.FileMode
	Flags     int
	Username  string
	Groupname string

	ModTime time.Time
	Open    bool

	SymlinkTarget string

	Content []byte
}

func (FakeFileStats) StringContents

func (stats FakeFileStats) StringContents() string

type FakeFileStatsRegistry

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

func NewFakeFileStatsRegistry

func NewFakeFileStatsRegistry() *FakeFileStatsRegistry

func (*FakeFileStatsRegistry) Get

func (fsr *FakeFileStatsRegistry) Get(path string) *FakeFileStats

func (*FakeFileStatsRegistry) GetAll

func (fsr *FakeFileStatsRegistry) GetAll() map[string]*FakeFileStats

func (*FakeFileStatsRegistry) Register

func (fsr *FakeFileStatsRegistry) Register(path string, stats *FakeFileStats)

func (*FakeFileStatsRegistry) Remove

func (fsr *FakeFileStatsRegistry) Remove(path string)

func (*FakeFileStatsRegistry) UnifiedPath

func (fsr *FakeFileStatsRegistry) UnifiedPath(path string) string

type FakeFileSystem

type FakeFileSystem struct {
	HomeDirUsername string
	HomeDirHomePath string

	ExpandPathPath     string
	ExpandPathExpanded string
	ExpandPathErr      error

	OpenFileErr error

	ReadFileError             error
	ReadFileWithOptsCallCount int

	WriteFileError            error
	WriteFileErrors           map[string]error
	WriteFileCallCount        int
	WriteFileQuietlyCallCount int

	SymlinkError error

	MkdirAllError error

	MkdirAllCallCount int

	ChangeTempRootErr error

	ChownErr       error
	ChownCallCount int
	ChmodErr       error
	ChmodCallCount int

	CopyFileError     error
	CopyFileCallCount int

	CopyDirError error

	RenameStub     renameFn
	RenameError    error
	RenameOldPaths []string
	RenameNewPaths []string

	RemoveAllStub removeAllFn

	ReadAndFollowLinkError error
	ReadlinkError          error

	StatWithOptsCallCount int
	StatCallCount         int

	TempFileError           error
	TempFileErrorsByPrefix  map[string]error
	ReturnTempFile          boshsys.File
	ReturnTempFiles         []boshsys.File
	ReturnTempFilesByPrefix map[string]boshsys.File

	TempDirDir   string
	TempDirDirs  []string
	TempDirError error

	GlobErr  error
	GlobStub globFn
	GlobErrs map[string]error

	WalkErr error

	TempRootPath string
	// contains filtered or unexported fields
}

func NewFakeFileSystem

func NewFakeFileSystem() *FakeFileSystem

func (*FakeFileSystem) ChangeTempRoot

func (fs *FakeFileSystem) ChangeTempRoot(tempRootPath string) error

func (*FakeFileSystem) Chmod

func (fs *FakeFileSystem) Chmod(path string, perm os.FileMode) error

func (*FakeFileSystem) Chown

func (fs *FakeFileSystem) Chown(path, username string) error

func (*FakeFileSystem) ConvergeFileContents

func (fs *FakeFileSystem) ConvergeFileContents(path string, content []byte, opts ...boshsys.ConvergeFileContentsOpts) (bool, error)

func (*FakeFileSystem) CopyDir

func (fs *FakeFileSystem) CopyDir(srcPath, dstPath string) error

func (*FakeFileSystem) CopyFile

func (fs *FakeFileSystem) CopyFile(srcPath, dstPath string) error

func (*FakeFileSystem) EnableStrictTempRootBehavior

func (fs *FakeFileSystem) EnableStrictTempRootBehavior()

func (*FakeFileSystem) ExpandPath

func (fs *FakeFileSystem) ExpandPath(path string) (string, error)

func (*FakeFileSystem) FileExists

func (fs *FakeFileSystem) FileExists(path string) bool

func (*FakeFileSystem) FindFileStats

func (fs *FakeFileSystem) FindFileStats(path string) (*FakeFileStats, error)

func (*FakeFileSystem) GetFileTestStat

func (fs *FakeFileSystem) GetFileTestStat(path string) *FakeFileStats

func (*FakeFileSystem) Glob

func (fs *FakeFileSystem) Glob(pattern string) (matches []string, err error)

func (*FakeFileSystem) HomeDir

func (fs *FakeFileSystem) HomeDir(username string) (string, error)

func (*FakeFileSystem) Ls

func (fs *FakeFileSystem) Ls(root string) ([]string, error)

func (*FakeFileSystem) Lstat

func (fs *FakeFileSystem) Lstat(path string) (os.FileInfo, error)

func (*FakeFileSystem) MkdirAll

func (fs *FakeFileSystem) MkdirAll(path string, perm os.FileMode) error

func (*FakeFileSystem) OpenFile

func (fs *FakeFileSystem) OpenFile(path string, flag int, perm os.FileMode) (boshsys.File, error)
func (fs *FakeFileSystem) ReadAndFollowLink(symlinkPath string) (string, error)

func (*FakeFileSystem) ReadFile

func (fs *FakeFileSystem) ReadFile(path string) ([]byte, error)

func (*FakeFileSystem) ReadFileString

func (fs *FakeFileSystem) ReadFileString(path string) (string, error)

func (*FakeFileSystem) ReadFileWithOpts

func (fs *FakeFileSystem) ReadFileWithOpts(path string, opts boshsys.ReadOpts) ([]byte, error)
func (fs *FakeFileSystem) Readlink(symlinkPath string) (string, error)

func (*FakeFileSystem) RecursiveGlob

func (fs *FakeFileSystem) RecursiveGlob(pattern string) (matches []string, err error)

func (*FakeFileSystem) RegisterMkdirAllError

func (fs *FakeFileSystem) RegisterMkdirAllError(path string, err error)

func (*FakeFileSystem) RegisterOpenFile

func (fs *FakeFileSystem) RegisterOpenFile(path string, file *FakeFile)

func (*FakeFileSystem) RegisterReadFileError

func (fs *FakeFileSystem) RegisterReadFileError(path string, err error)

func (*FakeFileSystem) RemoveAll

func (fs *FakeFileSystem) RemoveAll(path string) error

func (*FakeFileSystem) Rename

func (fs *FakeFileSystem) Rename(oldPath, newPath string) error

func (*FakeFileSystem) SetGlob

func (fs *FakeFileSystem) SetGlob(pattern string, matches ...[]string)

func (*FakeFileSystem) Stat

func (fs *FakeFileSystem) Stat(path string) (os.FileInfo, error)

func (*FakeFileSystem) StatHelper

func (fs *FakeFileSystem) StatHelper(path string) (os.FileInfo, error)

func (*FakeFileSystem) StatWithOpts

func (fs *FakeFileSystem) StatWithOpts(path string, opts boshsys.StatOpts) (os.FileInfo, error)
func (fs *FakeFileSystem) Symlink(oldPath, newPath string) (err error)

func (*FakeFileSystem) TempDir

func (fs *FakeFileSystem) TempDir(prefix string) (string, error)

func (*FakeFileSystem) TempFile

func (fs *FakeFileSystem) TempFile(prefix string) (file boshsys.File, err error)

func (*FakeFileSystem) UnregisterReadFileError

func (fs *FakeFileSystem) UnregisterReadFileError(path string)

func (*FakeFileSystem) Walk

func (fs *FakeFileSystem) Walk(root string, walkFunc filepath.WalkFunc) error

func (*FakeFileSystem) WriteFile

func (fs *FakeFileSystem) WriteFile(path string, content []byte) error

func (*FakeFileSystem) WriteFileQuietly

func (fs *FakeFileSystem) WriteFileQuietly(path string, content []byte) error

func (*FakeFileSystem) WriteFileString

func (fs *FakeFileSystem) WriteFileString(path, content string) error

type FakeFileType

type FakeFileType string
const (
	FakeFileTypeFile    FakeFileType = "file"
	FakeFileTypeSymlink FakeFileType = "symlink"
	FakeFileTypeDir     FakeFileType = "dir"
)

type FakeProcess

type FakeProcess struct {
	StartErr error

	WaitCh chan boshsys.Result

	Waited     bool
	WaitResult boshsys.Result

	TerminatedNicely               bool
	TerminatedNicelyCallBack       func(*FakeProcess)
	TerminateNicelyKillGracePeriod time.Duration
	TerminateNicelyErr             error

	Stdout io.Writer
	Stderr io.Writer
}

func (*FakeProcess) TerminateNicely

func (p *FakeProcess) TerminateNicely(killGracePeriod time.Duration) error

func (*FakeProcess) Wait

func (p *FakeProcess) Wait() <-chan boshsys.Result

Jump to

Keyboard shortcuts

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