mock

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReadFailed = fmt.Errorf("failed to read data")

Functions

func ConcatMultipleSlices

func ConcatMultipleSlices[T any](slices [][]T) []T

func RunCmd

func RunCmd(devMaker deviceMaker, dialog []Action, commands []cmd.Cmd, logger *zap.Logger) (cmdRes []cmd.CmdRes, resErr, serverErr, err error)

func RunDialog

func RunDialog(t *testing.T, devMaker deviceMaker, dialog []Action, command, expected string, creds credentials.Credentials)

func RunDialogWithDefaultCreds added in v1.0.15

func RunDialogWithDefaultCreds(t *testing.T, devMaker deviceMaker, dialog []Action, command, expected string)

func RunInvalidDialog

func RunInvalidDialog(t *testing.T, devMaker deviceMaker, dialog []Action, command string)

func RunInvalidDialogWithException

func RunInvalidDialogWithException(t *testing.T, devMaker deviceMaker, dialog []Action, command string, expErr error)

Types

type Action

type Action interface {
	Exec(reader io.ReadWriteCloser) error
}

type CloseAction

type CloseAction struct{}

Close action

func Close

func Close() CloseAction

func (CloseAction) Exec

func (a CloseAction) Exec(c io.ReadWriteCloser) error

type ExpectAction

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

Expect action

func Expect

func Expect(data string) ExpectAction

func (ExpectAction) Exec

type MockSSHServer

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

func NewMockSSHServer

func NewMockSSHServer(dialog []Action, opts ...MockSSHServerOption) (*MockSSHServer, error)

func (*MockSSHServer) GetAddress

func (m *MockSSHServer) GetAddress() (string, int)

func (*MockSSHServer) Run

func (m *MockSSHServer) Run(ctx context.Context) error

type MockSSHServerOption

type MockSSHServerOption func(*MockSSHServer)

func WithLogger

func WithLogger(logger *zap.Logger) MockSSHServerOption

func WithPassword

func WithPassword(password string) MockSSHServerOption

func WithPrivateKey

func WithPrivateKey(privateKey []byte) MockSSHServerOption

func WithUser

func WithUser(username string) MockSSHServerOption

type SendAction

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

Send action

func Send

func Send(data string) SendAction

func (SendAction) Exec

func (a SendAction) Exec(c io.ReadWriteCloser) error

type SendEchoAction

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

Send echo action

func SendEcho

func SendEcho(data string) SendEchoAction

func (SendEchoAction) Exec

type SleepAction added in v1.0.15

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

Sleep action

func Sleep added in v1.0.15

func Sleep(count int) SleepAction

func (SleepAction) Exec added in v1.0.15

func (a SleepAction) Exec(c io.ReadWriteCloser) error

Jump to

Keyboard shortcuts

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