exocomMock

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: MIT Imports: 8 Imported by: 0

README

#Mock implementation of ExoCom in Go A mock implementation of ExoCom-Dev for sending and receiving messages to your ExoServices in a test environment.

###Installation

$ go get github.com/Originate/exocomMock

Then simply import it into your testing environment with

import "github.com/Originate/exocomMock"

###Usage

exocom = exocomMock.New()
go exocom.Listen(4100)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExoComMock

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

ExoComMock is a mock implementation of ExoRelay, to be used for testing

func New

func New() *ExoComMock

New creates a new ExoComMock instance

func (*ExoComMock) AddMockReply

func (e *ExoComMock) AddMockReply(requestName string, data MockReplyData)

AddMockReply adds a mock reply for the given message

func (*ExoComMock) Close

func (e *ExoComMock) Close() error

Close takes this ExoComMock instance offline

func (*ExoComMock) CloseConnection

func (e *ExoComMock) CloseConnection() error

CloseConnection closes any open connection

func (*ExoComMock) GetReceivedMessages

func (e *ExoComMock) GetReceivedMessages() []structs.Message

GetReceivedMessages returns the received messages

func (*ExoComMock) HasConnection

func (e *ExoComMock) HasConnection() bool

HasConnection returns whether or not a socket is connected

func (*ExoComMock) Listen

func (e *ExoComMock) Listen(port int) error

Listen brings this ExoComMock instance online

func (*ExoComMock) Reset

func (e *ExoComMock) Reset() error

Reset closes and nils the socket and clears all received messages

func (*ExoComMock) Send

func (e *ExoComMock) Send(message structs.Message) error

Send sends the given message to the connected socket

func (*ExoComMock) WaitForConnection

func (e *ExoComMock) WaitForConnection() (structs.Message, error)

WaitForConnection waits for a socket to connect

func (*ExoComMock) WaitForMessageWithName

func (e *ExoComMock) WaitForMessageWithName(name string) (structs.Message, error)

WaitForMessageWithName waits to receive a message with the given name

type MockReplyData

type MockReplyData struct {
	Name    string
	Payload structs.MessagePayload
}

MockReplyData defines the data needed to mock a reply to a specific request

Jump to

Keyboard shortcuts

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