Documentation ¶
Index ¶
- Variables
- type AsynchronousMessage
- type Message
- func (m *Message) AsType(t interface{}) *Message
- func (m *Message) ConsumedBy(handler MessageConsumer) *Message
- func (m *Message) ExpectsToReceive(description string) *Message
- func (m *Message) Given(state models.ProviderStateV3) *Message
- func (m *Message) Verify(t *testing.T) error
- func (m *Message) WithBinaryContent(contentType string, body []byte) *Message
- func (m *Message) WithContent(contentType string, body []byte) *Message
- func (m *Message) WithJSONContent(content interface{}) *Message
- func (m *Message) WithMetadata(metadata map[string]string) *Message
- type MessageBody
- type MessageConfig
- type MessageConsumer
- type MessageHandler
- type MessageHandlers
- type MessageMetadata
- type MessagePactV3
- type MessageProducer
- type MessageVerifier
- type VerifyMessageRequest
Constants ¶
This section is empty.
Variables ¶
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 ¶
// 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 ¶
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) WithBinaryContent ¶
WithBinaryContent accepts a binary payload
func (*Message) WithContent ¶
WithContent specifies the payload in bytes that the consumer expects to receive
func (*Message) WithJSONContent ¶
WithJSONContent specifies the payload as an object (to be marshalled to WithJSONContent) that is expected to be consumed
type MessageBody ¶
type MessageBody interface{}
type MessageConfig ¶
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.