slackdeps

package
v0.0.0-...-d54492c Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MockCustomConfigDirectory = "/tmp/tmp.user.name.123"

MockCustomConfigDirectory is a custom config directory for ConfigDirFlag

View Source
const MockHomeDirectory = "/Users/user.name"

MockHomeDirectory is the default returned by UserHomeDir().

View Source
const MockWorkingDirectory = "/Users/user.name/project"

MockWorkingDirectory is the default returned by Getwd().

Variables

This section is empty.

Functions

func NewFs

func NewFs() afero.Fs

NewFs creates a new afero operating system file system

Types

type Browser

type Browser interface {
	OpenURL(url string)
}

Browser contains methods for visiting a webpage

type BrowserMock

type BrowserMock struct {
	mock.Mock
}

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.

func (*BrowserMock) OpenURL

func (m *BrowserMock) OpenURL(url string)

OpenURL mock.

type FileInfoCharDevice

type FileInfoCharDevice struct {
	os.FileInfo
}

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

type FileInfoNamedPipe struct {
	os.FileInfo
}

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 FileMock

type FileMock struct {
	FileInfo os.FileInfo
	mock.Mock
}

FileMock contains mockable information about a file

func NewFileMock

func NewFileMock() *FileMock

NewFileMock creates a mock for a file

func (*FileMock) Stat

func (m *FileMock) Stat() (os.FileInfo, error)

Stat returns information about a mocked file

type FsMock

type FsMock struct {
	mock.Mock
	afero.MemMapFs
}

FsMock is composed of the afero memory-based file system and testify mocking package.

func NewFsMock

func NewFsMock() *FsMock

NewFsMock creates a mock for the file system.

func (*FsMock) Mkdir

func (m *FsMock) Mkdir(path string, perm fs.FileMode) (_err error)

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

func (m *FsMock) MkdirAll(path string, perm fs.FileMode) (_err error)

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

func (m *FsMock) OpenFile(name string, flag int, perm fs.FileMode) (_file afero.File, _err error)

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.

func (*FsMock) Stat

func (m *FsMock) Stat(path string) (_info fs.FileInfo, _err error)

Stat 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

func NewBrowser(out io.Writer) GoBrowser

NewBrowser prepares a browser for visiting URLs

func (GoBrowser) OpenURL

func (bw GoBrowser) OpenURL(url string)

OpenURL opens the URL in browser or otherwise prints the URL

type Os

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

Os contains os package functions that need to be mockable for testing

func NewOs

func NewOs() *Os

NewOs creates a new SlackOs

func (*Os) Exit

func (c *Os) Exit(code int)

Exit exits the program with a return code

func (*Os) GetExecutionDir

func (c *Os) GetExecutionDir() string

GetExecutionDir returns the absolute path where the process started execution

func (*Os) Getenv

func (c *Os) Getenv(key string) (value string)

Getenv defaults to `os.Getenv` and can be mocked to test

func (*Os) Getwd

func (c *Os) Getwd() (dir string, err error)

Getwd defaults to `os.Getwd` and can be mocked to test

func (*Os) Glob

func (c *Os) Glob(pattern string) (matches []string, err error)

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

func (c *Os) IsNotExist(err error) bool

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

func (c *Os) LookPath(file string) (path string, err error)

LookPath is a safe alternative to `exec.LookPath()` that reduces security risks on Windows and has better PATH support.

func (*Os) LookupEnv

func (c *Os) LookupEnv(key string) (value string, present bool)

LookupEnv defaults to `os.LookupEnv` and can be mocked to test

func (*Os) SetExecutionDir

func (c *Os) SetExecutionDir(dirPathAbs string)

SetExecutionDir sets the absolute path where the process started execution

func (*Os) Setenv

func (c *Os) Setenv(key string, value string) error

Setenv defaults to `os.Setenv` and can be mocked to test

func (*Os) Stdout

func (c *Os) Stdout() types.File

Stdout returns the file descriptor for stdout

func (*Os) UserHomeDir

func (c *Os) UserHomeDir() (string, error)

UserHomeDir returns the current user's home directory and can be mocked to test

type OsMock

type OsMock struct {
	mock.Mock
}

OsMock mocks the client's Os struct.

func NewOsMock

func NewOsMock() *OsMock

NewOsMock creates a new OsMock

func (*OsMock) AddDefaultMocks

func (m *OsMock) AddDefaultMocks()

AddDefaultMocks installs the default mock actions to fallback on.

func (*OsMock) Exit

func (m *OsMock) Exit(code int)

Exit mocks exiting the program with a return code, but does not actually exit

func (*OsMock) GetExecutionDir

func (m *OsMock) GetExecutionDir() string

GetExecutionDir mocks returning the absolute path where the process started execution

func (*OsMock) Getenv

func (m *OsMock) Getenv(key string) (value string)

Getenv mocks returning an environment variable

func (*OsMock) Getwd

func (m *OsMock) Getwd() (_dir string, _err error)

Getwd mocks returning the working directory.

func (*OsMock) Glob

func (m *OsMock) Glob(pattern string) (matches []string, err error)

func (*OsMock) IsNotExist

func (m *OsMock) IsNotExist(err error) (_bool bool)

IsNotExist returns a boolean indicating whether the provided error is known to report that a file or directory does not exist

func (*OsMock) LookPath

func (m *OsMock) LookPath(file string) (path string, err error)

LookPath mocks finding the path of an executable

func (*OsMock) LookupEnv

func (m *OsMock) LookupEnv(key string) (value string, present bool)

LookupEnv mocks searching for an environment variable

func (*OsMock) SetExecutionDir

func (m *OsMock) SetExecutionDir(dirPathAbs string)

SetExecutionDir mocks setting the absolute path where the process started execution

func (*OsMock) Setenv

func (m *OsMock) Setenv(key string, value string) error

Setenv mocks the setting of an environment variable

func (*OsMock) Stdout

func (m *OsMock) Stdout() types.File

Stdout mocks the stdout with a file that can be adjusted

func (*OsMock) UserHomeDir

func (m *OsMock) UserHomeDir() (_dir string, _err error)

UserHomeDir mocks returning the home directory.

Jump to

Keyboard shortcuts

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