mock

package
v1.0.29 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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