test

package
v0.0.0-...-8fd811e Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertRowsEqual

func AssertRowsEqual(t *testing.T, db *sqlx.DB, expectedRows []map[string]interface{}, query string, params []interface{})

func ConvertDbRowsToMapSlice

func ConvertDbRowsToMapSlice(dbRows *sqlx.Rows) ([]map[string]interface{}, error)

func Md5Hash

func Md5Hash(input string) []byte

func NewMockChannel

func NewMockChannel() (*ReadWriter, *ReadWriter)

Types

type ChannelMock

type ChannelMock struct {
	ssh.Channel

	Writes []string
}

func (*ChannelMock) Close

func (c *ChannelMock) Close() error

func (*ChannelMock) Write

func (c *ChannelMock) Write(d []byte) (int, error)

type ConnMock

type ConnMock struct {
	ssh.Conn

	DoneChannel chan bool

	ReturnOk              bool
	ReturnResponsePayload []byte
	ReturnErr             error
	ReturnRemoteAddr      net.Addr

	ChannelMocks map[string]*ChannelMock
	// contains filtered or unexported fields
}

func NewConnMock

func NewConnMock() *ConnMock

func (*ConnMock) InputSendRequest

func (c *ConnMock) InputSendRequest() (name string, wantReply bool, payload []byte)

func (*ConnMock) OpenChannel

func (c *ConnMock) OpenChannel(name string, data []byte) (ssh.Channel, <-chan *ssh.Request, error)

func (*ConnMock) RemoteAddr

func (c *ConnMock) RemoteAddr() net.Addr

func (*ConnMock) SendRequest

func (c *ConnMock) SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)

type FileAPIMock

type FileAPIMock struct {
	mock.Mock
	SetReadFileDestFunc func(dest interface{})
}

func NewFileAPIMock

func NewFileAPIMock() *FileAPIMock

func (*FileAPIMock) ChangeMode

func (f *FileAPIMock) ChangeMode(path string, targetMode os.FileMode) error

func (*FileAPIMock) ChangeOwner

func (f *FileAPIMock) ChangeOwner(path, owner, group string) error

func (*FileAPIMock) CreateDirIfNotExists

func (f *FileAPIMock) CreateDirIfNotExists(path string, mode os.FileMode) (wasCreated bool, err error)

func (*FileAPIMock) CreateFile

func (f *FileAPIMock) CreateFile(path string, sourceReader io.Reader) (writtenBytes int64, err error)

func (*FileAPIMock) Exist

func (f *FileAPIMock) Exist(path string) (bool, error)

func (*FileAPIMock) GetFileMode

func (f *FileAPIMock) GetFileMode(file string) (os.FileMode, error)

func (*FileAPIMock) GetFileOwnerAndGroup

func (f *FileAPIMock) GetFileOwnerAndGroup(file string) (uid, gid uint32, err error)

func (*FileAPIMock) MakeDirAll

func (f *FileAPIMock) MakeDirAll(dir string) error

func (*FileAPIMock) Open

func (f *FileAPIMock) Open(file string) (io.ReadWriteCloser, error)

func (*FileAPIMock) ReadDir

func (f *FileAPIMock) ReadDir(dir string) ([]os.FileInfo, error)

func (*FileAPIMock) ReadJSON

func (f *FileAPIMock) ReadJSON(file string, dest interface{}) error

func (*FileAPIMock) Remove

func (f *FileAPIMock) Remove(name string) error

func (*FileAPIMock) Rename

func (f *FileAPIMock) Rename(oldPath, newPath string) error

func (*FileAPIMock) Write

func (f *FileAPIMock) Write(fileName string, content string) error

func (*FileAPIMock) WriteJSON

func (f *FileAPIMock) WriteJSON(file string, content interface{}) error

type FileMock

type FileMock struct {
	os.FileInfo
	ReturnName    string
	ReturnModTime time.Time
}

func (*FileMock) ModTime

func (f *FileMock) ModTime() time.Time

func (*FileMock) Name

func (f *FileMock) Name() string

type ReadCloserMock

type ReadCloserMock struct {
	Reader io.Reader
	mock.Mock
}

func (*ReadCloserMock) Close

func (rcm *ReadCloserMock) Close() error

func (*ReadCloserMock) Read

func (rcm *ReadCloserMock) Read(p []byte) (n int, err error)

type ReadWriteCloserMock

type ReadWriteCloserMock struct {
	ReadCloserMock
	Writer io.Writer
}

func (*ReadWriteCloserMock) Write

func (rcm *ReadWriteCloserMock) Write(p []byte) (n int, err error)

type ReadWriter

type ReadWriter struct {
	io.Reader
	io.WriteCloser
}

type SysUserProviderMock

type SysUserProviderMock struct {
	mock.Mock
}

func (*SysUserProviderMock) GetCurrentUserAndGroup

func (supm *SysUserProviderMock) GetCurrentUserAndGroup() (*user.User, *user.Group, error)

func (*SysUserProviderMock) GetGidByName

func (supm *SysUserProviderMock) GetGidByName(group string) (gid uint32, err error)

func (*SysUserProviderMock) GetUIDByName

func (supm *SysUserProviderMock) GetUIDByName(user string) (uid uint32, err error)

Jump to

Keyboard shortcuts

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