test

package
v0.0.0-...-330c09c Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockMessageMerger

func MockMessageMerger(old interface{}, new interface{}) interface{}

func MustGenerateTestTLSConf

func MustGenerateTestTLSConf(t *testing.T, ctx context.Context) (func() (*tls.Config, error), *tls.Dialer)

func MustSetupInsecureControlPair

func MustSetupInsecureControlPair(t *testing.T) (context.Context, control.Service, context.Context, control.Service)

MustSetupInsecureControlPair setup a plain connection with a server and a client

func MustSetupSecureControlPair

func MustSetupSecureControlPair(t *testing.T) (context.Context, control.Service, context.Context, control.Service)

MustSetupSecureControlPair setup a server and a client using tls

func ParseMockMessage

func ParseMockMessage(bytes []byte) (interface{}, error)

func SendReceiveTest

func SendReceiveTest(t *testing.T, sender control.Service, receiver control.Service)

Types

type ConnectionMock

type ConnectionMock struct {
	ErrorsCh chan error
	// contains filtered or unexported fields
}

func NewConnectionMock

func NewConnectionMock() *ConnectionMock

func (*ConnectionMock) Errors

func (c *ConnectionMock) Errors() <-chan error

func (*ConnectionMock) PushInboundMessage

func (c *ConnectionMock) PushInboundMessage(msg *control.Message)

func (*ConnectionMock) ReadMessage

func (c *ConnectionMock) ReadMessage() *control.Message

func (*ConnectionMock) WaitAtLeastOneOutboundMessage

func (c *ConnectionMock) WaitAtLeastOneOutboundMessage() []*control.Message

func (*ConnectionMock) WriteMessage

func (c *ConnectionMock) WriteMessage(msg *control.Message)

type MockPayload

type MockPayload string
var SomeMockPayload MockPayload = "Hello world!"

func (MockPayload) MarshalBinary

func (m MockPayload) MarshalBinary() (data []byte, err error)

func (*MockPayload) UnmarshalBinary

func (m *MockPayload) UnmarshalBinary(data []byte) error

type MockTLSDialerFactory

type MockTLSDialerFactory tls.Dialer

func (*MockTLSDialerFactory) GenerateTLSDialer

func (m *MockTLSDialerFactory) GenerateTLSDialer(*net.Dialer) (*tls.Dialer, error)

type ServiceMock

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

func NewServiceMock

func NewServiceMock() *ServiceMock

func (*ServiceMock) AckIt

func (s *ServiceMock) AckIt(code control.OpCode)

AckIt propagates the ack for the last message sent using the provided opcode

func (*ServiceMock) ErrorHandler

func (s *ServiceMock) ErrorHandler(handler control.ErrorHandler)

func (*ServiceMock) InvokeErrorHandler

func (s *ServiceMock) InvokeErrorHandler(ctx context.Context, err error)

func (*ServiceMock) InvokeMessageHandler

func (s *ServiceMock) InvokeMessageHandler(ctx context.Context, message *control.Message) bool

InvokeMessageHandler invokes the registered message handler and returns true if the message was acked back

func (*ServiceMock) InvokeMessageHandlerWithErr

func (s *ServiceMock) InvokeMessageHandlerWithErr(ctx context.Context, message *control.Message) error

InvokeMessageHandlerWithErr invokes the registered message handler and returns the eventual error if the message was acked back with an error

func (*ServiceMock) MessageHandler

func (s *ServiceMock) MessageHandler(handler control.MessageHandler)

func (*ServiceMock) SendAndWaitForAck

func (s *ServiceMock) SendAndWaitForAck(opcode control.OpCode, payload encoding.BinaryMarshaler) error

Jump to

Keyboard shortcuts

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