message

package
v2.0.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PACT_MESSAGE_METADATA_HEADER = "PACT_MESSAGE_METADATA"

Functions

This section is empty.

Types

type AsynchronousMessage

type AsynchronousMessage struct {
	// Message Body
	Content interface{} `json:"contents"`

	// Provider state to be written into the Pact file
	States []models.ProviderStateV3 `json:"providerStates"`

	// Message metadata
	Metadata matchers.MetadataMatcher `json:"metadata"`

	// Description to be written into the Pact file
	Description string `json:"description"`
}

V3 Message (Asynchronous only)

type Message

type Message struct {

	// Type to Marshal content into when sending back to the consumer
	// Defaults to interface{}
	Type interface{}
	// contains filtered or unexported fields
}

Message is a representation of a single, unidirectional message e.g. MQ, pub/sub, Websocket, Lambda Message is the main implementation of the Pact Message interface.

func (*Message) AsType

func (m *Message) AsType(t interface{}) *Message

// AsType specifies that the content sent through to the consumer handler should be sent as the given type

func (*Message) ConsumedBy

func (m *Message) ConsumedBy(handler MessageConsumer) *Message

The function that will consume the message

func (*Message) ExpectsToReceive

func (m *Message) ExpectsToReceive(description string) *Message

ExpectsToReceive specifies the content it is expecting to be given from the Provider. The function must be able to handle this message for the interaction to succeed.

func (*Message) Given

func (m *Message) Given(state models.ProviderStateV3) *Message

Given specifies a provider state. Optional.

func (*Message) Verify

func (m *Message) Verify(t *testing.T) error

The function that will consume the message

func (*Message) WithBinaryContent

func (m *Message) WithBinaryContent(contentType string, body []byte) *Message

WithBinaryContent accepts a binary payload

func (*Message) WithContent

func (m *Message) WithContent(contentType string, body []byte) *Message

WithContent specifies the payload in bytes that the consumer expects to receive

func (*Message) WithJSONContent

func (m *Message) WithJSONContent(content interface{}) *Message

WithJSONContent specifies the payload as an object (to be marshalled to WithJSONContent) that is expected to be consumed

func (*Message) WithMetadata

func (m *Message) WithMetadata(metadata map[string]string) *Message

WithMetadata specifies message-implementation specific metadata to go with the content func (m *Message) WithMetadata(metadata MapMatcher) *Message {

type MessageBody

type MessageBody interface{}

type MessageConfig

type MessageConfig struct {
	Consumer string
	Provider string
	PactDir  string
}

type MessageConsumer

type MessageConsumer func(AsynchronousMessage) error

MessageConsumer receives a message and must be able to parse the content

type MessageHandler

type MessageHandler func([]models.ProviderStateV3) (MessageBody, MessageMetadata, error)

MessageHandler is a provider function that generates a message for a Consumer given a Message context (state, description etc.)

type MessageHandlers

type MessageHandlers map[string]MessageHandler

MessageHandlers is a list of handlers ordered by description

type MessageMetadata

type MessageMetadata map[string]interface{}

type MessagePactV3

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

func NewMessagePactV3

func NewMessagePactV3(config MessageConfig) (*MessagePactV3, error)

func (*MessagePactV3) AddMessage

func (p *MessagePactV3) AddMessage() *Message

AddMessage creates a new asynchronous consumer expectation

func (*MessagePactV3) Verify

func (p *MessagePactV3) Verify(t *testing.T, message *Message, handler MessageConsumer) error

VerifyMessageConsumer is a test convience function for VerifyMessageConsumerRaw, accepting an instance of `*testing.T`

type MessageProducer

type MessageProducer MessageHandler

type MessageVerifier

type MessageVerifier struct {
	// ClientTimeout specifies how long to wait for Pact CLI to start
	// Can be increased to reduce likelihood of intermittent failure
	// Defaults to 10s
	ClientTimeout time.Duration
}

func (*MessageVerifier) Verify

func (v *MessageVerifier) Verify(t *testing.T, request VerifyMessageRequest) error

type VerifyMessageRequest

type VerifyMessageRequest struct {
	provider.VerifyRequest
	// MessageHandlers contains a mapped list of message handlers for a provider
	// that will be rable to produce the correct message format for a given
	// consumer interaction
	MessageHandlers MessageHandlers
}

VerifyMessageRequest contains the verification params.

Jump to

Keyboard shortcuts

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