Documentation
¶
Index ¶
- Constants
- func NewFs() afero.Fs
- type Browser
- type BrowserMock
- type FileInfoCharDevice
- type FileInfoNamedPipe
- type FileMock
- type FsMock
- func (m *FsMock) Mkdir(path string, perm fs.FileMode) (_err error)
- func (m *FsMock) MkdirAll(path string, perm fs.FileMode) (_err error)
- func (m *FsMock) OpenFile(name string, flag int, perm fs.FileMode) (_file afero.File, _err error)
- func (m *FsMock) Stat(path string) (_info fs.FileInfo, _err error)
- type GoBrowser
- type Os
- func (c *Os) Exit(code int)
- func (c *Os) GetExecutionDir() string
- func (c *Os) Getenv(key string) (value string)
- func (c *Os) Getwd() (dir string, err error)
- func (c *Os) Glob(pattern string) (matches []string, err error)
- func (c *Os) IsNotExist(err error) bool
- func (c *Os) LookPath(file string) (path string, err error)
- func (c *Os) LookupEnv(key string) (value string, present bool)
- func (c *Os) SetExecutionDir(dirPathAbs string)
- func (c *Os) Setenv(key string, value string) error
- func (c *Os) Stdout() types.File
- func (c *Os) UserHomeDir() (string, error)
- type OsMock
- func (m *OsMock) AddDefaultMocks()
- func (m *OsMock) Exit(code int)
- func (m *OsMock) GetExecutionDir() string
- func (m *OsMock) Getenv(key string) (value string)
- func (m *OsMock) Getwd() (_dir string, _err error)
- func (m *OsMock) Glob(pattern string) (matches []string, err error)
- func (m *OsMock) IsNotExist(err error) (_bool bool)
- func (m *OsMock) LookPath(file string) (path string, err error)
- func (m *OsMock) LookupEnv(key string) (value string, present bool)
- func (m *OsMock) SetExecutionDir(dirPathAbs string)
- func (m *OsMock) Setenv(key string, value string) error
- func (m *OsMock) Stdout() types.File
- func (m *OsMock) UserHomeDir() (_dir string, _err error)
Constants ¶
const MockCustomConfigDirectory = "/tmp/tmp.user.name.123"
MockCustomConfigDirectory is a custom config directory for ConfigDirFlag
const MockHomeDirectory = "/Users/user.name"
MockHomeDirectory is the default returned by UserHomeDir().
const MockWorkingDirectory = "/Users/user.name/project"
MockWorkingDirectory is the default returned by Getwd().
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Browser ¶
type Browser interface {
OpenURL(url string)
}
Browser contains methods for visiting a webpage
type BrowserMock ¶
BrowserMock mocks the client's Browser struct.
func NewBrowserMock ¶
func NewBrowserMock() *BrowserMock
NewBrowserMock creates a mock for some Browser functions.
func (*BrowserMock) AddDefaultMocks ¶
func (m *BrowserMock) AddDefaultMocks()
AddDefaultMocks installs the default mock actions to fallback on.
type FileInfoCharDevice ¶
FileInfoCharDevice holds mocked info of a char device file type
func (*FileInfoCharDevice) Mode ¶
func (fi *FileInfoCharDevice) Mode() os.FileMode
Mode returns the status bits of a char device file
type FileInfoNamedPipe ¶
FileInfoNamedPipe holds mocked info of a named pipe file type
func (*FileInfoNamedPipe) Mode ¶
func (fi *FileInfoNamedPipe) Mode() os.FileMode
Mode returns the status bits of a named pipe file
type FsMock ¶
FsMock is composed of the afero memory-based file system and testify mocking package.
func (*FsMock) Mkdir ¶
Mkdir is a hybrid mock function. 1. When no mock is defined, then it will call the Afero memory-based file system. This is the most common scenario. 2. When a mock is defined, then the mock response is used instead of calling Afero's memory-based file system.
func (*FsMock) MkdirAll ¶
MkdirAll is a hybrid mock function. 1. When no mock is defined, then it will call the Afero memory-based file system. This is the most common scenario. 2. When a mock is defined, then the mock response is used instead of calling Afero's memory-based file system.
This is accomplished by catching a runtime panic. When there are no mocks defined, then m.Called() will panic. The defer will capture the panic and recover by calling the original memory-based MkdirAll. The named return value (_err) is then set at the last moment before being returned to the caller.
func (*FsMock) OpenFile ¶
OpenFile is a hybrid mock function. 1. When no mock is defined, then it will call the Afero memory-based file system. This is the most common scenario. 2. When a mock is defined, then the mock response is used instead of calling Afero's memory-based file system.
type GoBrowser ¶
type GoBrowser struct {
// contains filtered or unexported fields
}
GoBrowser wraps the browser to handle errors
func NewBrowser ¶
NewBrowser prepares a browser for visiting URLs
type Os ¶
type Os struct {
// contains filtered or unexported fields
}
Os contains os package functions that need to be mockable for testing
func (*Os) GetExecutionDir ¶
GetExecutionDir returns the absolute path where the process started execution
func (*Os) Glob ¶
Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. Reference: https://pkg.go.dev/path/filepath#Glob
func (*Os) IsNotExist ¶
IsNotExist returns a boolean indicating whether the provided error is known to report that a file or directory does not exist and can be mocked to test
func (*Os) LookPath ¶
LookPath is a safe alternative to `exec.LookPath()` that reduces security risks on Windows and has better PATH support.
func (*Os) SetExecutionDir ¶
SetExecutionDir sets the absolute path where the process started execution
func (*Os) UserHomeDir ¶
UserHomeDir returns the current user's home directory and can be mocked to test
type OsMock ¶
OsMock mocks the client's Os struct.
func (*OsMock) AddDefaultMocks ¶
func (m *OsMock) AddDefaultMocks()
AddDefaultMocks installs the default mock actions to fallback on.
func (*OsMock) GetExecutionDir ¶
GetExecutionDir mocks returning the absolute path where the process started execution
func (*OsMock) IsNotExist ¶
IsNotExist returns a boolean indicating whether the provided error is known to report that a file or directory does not exist
func (*OsMock) SetExecutionDir ¶
SetExecutionDir mocks setting the absolute path where the process started execution
func (*OsMock) UserHomeDir ¶
UserHomeDir mocks returning the home directory.