testscommon

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMockMarshaller = errors.New("MarshallerMock generic error")

ErrMockMarshaller -

View Source
var ErrNilObjectToMarshal = errors.New("nil object to serialize from")

ErrNilObjectToMarshal -

Functions

func NewHttpTestEchoHandler

func NewHttpTestEchoHandler() *httptest.Server

NewHttpTestEchoHandler -

Types

type HttpServerStub

type HttpServerStub struct {
	ListenAndServeCalled func() error
	ShutdownCalled       func(ctx context.Context) error
}

HttpServerStub -

func (*HttpServerStub) ListenAndServe

func (h *HttpServerStub) ListenAndServe() error

ListenAndServe -

func (*HttpServerStub) Shutdown

func (h *HttpServerStub) Shutdown(ctx context.Context) error

Shutdown -

type LoggerMock

type LoggerMock struct {
}

LoggerMock -

func (LoggerMock) Debug

func (c LoggerMock) Debug(message string, args ...interface{})

Debug will print a debug log

func (LoggerMock) Error

func (c LoggerMock) Error(message string, args ...interface{})

Error will print an error log

func (LoggerMock) Info

func (c LoggerMock) Info(message string, args ...interface{})

Info will print an info log

func (LoggerMock) IsInterfaceNil

func (c LoggerMock) IsInterfaceNil() bool

IsInterfaceNil returns false as the struct doesn't use pointer receivers

func (LoggerMock) LogIfError

func (c LoggerMock) LogIfError(err error, args ...interface{})

LogIfError will print an error if it is not nil

func (LoggerMock) Trace

func (c LoggerMock) Trace(message string, args ...interface{})

Trace will print a trace log

func (LoggerMock) Warn

func (c LoggerMock) Warn(message string, args ...interface{})

Warn will print a warn log

type LoggerStub

type LoggerStub struct {
	TraceCalled      func(message string, args ...interface{})
	DebugCalled      func(message string, args ...interface{})
	InfoCalled       func(message string, args ...interface{})
	WarnCalled       func(message string, args ...interface{})
	ErrorCalled      func(message string, args ...interface{})
	LogIfErrorCalled func(err error, args ...interface{})
}

LoggerStub -

func (*LoggerStub) Debug

func (l *LoggerStub) Debug(message string, args ...interface{})

Debug -

func (*LoggerStub) Error

func (l *LoggerStub) Error(message string, args ...interface{})

Error -

func (*LoggerStub) Info

func (l *LoggerStub) Info(message string, args ...interface{})

Info -

func (*LoggerStub) IsInterfaceNil

func (l *LoggerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*LoggerStub) LogIfError

func (l *LoggerStub) LogIfError(err error, args ...interface{})

LogIfError -

func (*LoggerStub) Trace

func (l *LoggerStub) Trace(message string, args ...interface{})

Trace -

func (*LoggerStub) Warn

func (l *LoggerStub) Warn(message string, args ...interface{})

Warn -

type MarshallerMock

type MarshallerMock struct {
	Fail bool
}

MarshallerMock that will be used for testing

func (*MarshallerMock) IsInterfaceNil

func (mm *MarshallerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MarshallerMock) Marshal

func (mm *MarshallerMock) Marshal(obj interface{}) ([]byte, error)

Marshal converts the input object in a slice of bytes

func (*MarshallerMock) Unmarshal

func (mm *MarshallerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal applies the serialized values over an instantiated object

type MarshallerStub added in v1.0.2

type MarshallerStub struct {
	MarshalCalled   func(obj interface{}) ([]byte, error)
	UnmarshalCalled func(obj interface{}, buff []byte) error
}

MarshallerStub -

func (*MarshallerStub) IsInterfaceNil added in v1.0.2

func (ms *MarshallerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*MarshallerStub) Marshal added in v1.0.2

func (ms *MarshallerStub) Marshal(obj interface{}) ([]byte, error)

Marshal -

func (*MarshallerStub) Unmarshal added in v1.0.2

func (ms *MarshallerStub) Unmarshal(obj interface{}, buff []byte) error

Unmarshal -

type PayloadHandlerStub

type PayloadHandlerStub struct {
	ProcessPayloadCalled func(payload []byte, topic string) error
	CloseCalled          func() error
}

PayloadHandlerStub -

func (*PayloadHandlerStub) Close

func (ph *PayloadHandlerStub) Close() error

Close -

func (*PayloadHandlerStub) IsInterfaceNil

func (ph *PayloadHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PayloadHandlerStub) ProcessPayload

func (ph *PayloadHandlerStub) ProcessPayload(payload []byte, topic string) error

ProcessPayload -

type ProtoMarshallerMock added in v1.0.2

type ProtoMarshallerMock struct {
}

ProtoMarshallerMock implements marshaling with protobuf

func (*ProtoMarshallerMock) IsInterfaceNil added in v1.0.2

func (pmm *ProtoMarshallerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ProtoMarshallerMock) Marshal added in v1.0.2

func (pmm *ProtoMarshallerMock) Marshal(obj interface{}) ([]byte, error)

Marshal does the actual serialization of an object The object to be serialized must implement the gogoProtoObj interface

func (*ProtoMarshallerMock) Unmarshal added in v1.0.2

func (pmm *ProtoMarshallerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal does the actual deserialization of an object The object to be deserialized must implement the gogoProtoObj interface

type WebsocketConnectionStub

type WebsocketConnectionStub struct {
	OpenConnectionCalled func(url string) error
	ReadMessageCalled    func() (messageType int, payload []byte, err error)
	WriteMessageCalled   func(messageType int, data []byte) error
	IsOpenCalled         func() bool
	GetIDCalled          func() string
	CloseCalled          func() error
}

WebsocketConnectionStub -

func (*WebsocketConnectionStub) Close

func (w *WebsocketConnectionStub) Close() error

Close -

func (*WebsocketConnectionStub) GetID

func (w *WebsocketConnectionStub) GetID() string

GetID -

func (*WebsocketConnectionStub) IsInterfaceNil

func (w *WebsocketConnectionStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*WebsocketConnectionStub) IsOpen added in v1.0.1

func (w *WebsocketConnectionStub) IsOpen() bool

IsOpen --

func (*WebsocketConnectionStub) OpenConnection

func (w *WebsocketConnectionStub) OpenConnection(url string) error

OpenConnection -

func (*WebsocketConnectionStub) ReadMessage

func (w *WebsocketConnectionStub) ReadMessage() (messageType int, payload []byte, err error)

ReadMessage -

func (*WebsocketConnectionStub) WriteMessage

func (w *WebsocketConnectionStub) WriteMessage(messageType int, data []byte) error

WriteMessage -

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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