v4

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsynchronousConsumer

type AsynchronousConsumer func(AsynchronousMessage) error

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

type AsynchronousMessage

type AsynchronousMessage MessageContents

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

type AsynchronousMessageBuilder

type AsynchronousMessageBuilder struct {

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

func (*AsynchronousMessageBuilder) 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 (*AsynchronousMessageBuilder) Given

Given specifies a provider state. Optional.

func (*AsynchronousMessageBuilder) GivenWithParameter

Given specifies a provider state. Optional.

type AsynchronousMessageWithConsumer

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

func (*AsynchronousMessageWithConsumer) Verify

The function that will consume the message

type AsynchronousMessageWithContents

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

func (*AsynchronousMessageWithContents) AsType

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

func (*AsynchronousMessageWithContents) ConsumedBy

The function that will consume the message

type AsynchronousMessageWithPlugin

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

func (*AsynchronousMessageWithPlugin) WithContents

func (s *AsynchronousMessageWithPlugin) WithContents(contents string, contentType string) *AsynchronousMessageWithPluginContents

type AsynchronousMessageWithPluginContents

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

func (*AsynchronousMessageWithPluginContents) ExecuteTest

func (s *AsynchronousMessageWithPluginContents) ExecuteTest(t *testing.T, integrationTest func(m AsynchronousMessage) error) error

func (*AsynchronousMessageWithPluginContents) StartTransport

func (s *AsynchronousMessageWithPluginContents) StartTransport(transport string, address string, config map[string][]interface{}) *AsynchronousMessageWithTransport

type AsynchronousMessageWithTransport

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

func (*AsynchronousMessageWithTransport) ExecuteTest

func (s *AsynchronousMessageWithTransport) ExecuteTest(t *testing.T, integrationTest func(tc TransportConfig, m AsynchronousMessage) error) error

type AsynchronousPact

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

func NewAsynchronousPact

func NewAsynchronousPact(config Config) (*AsynchronousPact, error)

func (*AsynchronousPact) AddAsynchronousMessage

func (p *AsynchronousPact) AddAsynchronousMessage() *AsynchronousMessageBuilder

AddMessage creates a new asynchronous consumer expectation

func (*AsynchronousPact) AddMessage

AddMessage creates a new asynchronous consumer expectation Deprecated: use AddAsynchronousMessage() instead

func (*AsynchronousPact) Verify

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

type Config

type Config struct {
	Consumer string
	Provider string
	PactDir  string
}

type MessageContents

type MessageContents struct {
	// Message Body
	Contents []byte

	// Body is the attempt to reify the message body back into a specified type
	// Not populated for synchronous  messages
	Body interface{} `json:"contents"`
}

V3 Message (Asynchronous only)

type Metadata

type Metadata map[string]interface{}

type PluginConfig

type PluginConfig struct {
	Plugin  string
	Version string
}

type RequestBuilderFunc

type RequestBuilderFunc func(*SynchronousMessageWithRequestBuilder)

type ResponseBuilderFunc

type ResponseBuilderFunc func(*SynchronousMessageWithResponseBuilder)

type SynchronousMessage

type SynchronousMessage struct {
	// TODO: should we pass this in? Probably need to be able to reify the message
	//       in these cases
	Request MessageContents

	// Currently only support a single response, but support may be added for multiple
	// responses to be given in the future
	Response []MessageContents
}

SynchronousMessage contains a req/res message It is currently an empty struct to allow future expansion

type SynchronousMessageBuilder

type SynchronousMessageBuilder struct {
}

SynchronousMessageBuilder is a representation of a single, bidirectional message

type SynchronousMessageWithPlugin

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

func (*SynchronousMessageWithPlugin) UsingPlugin

UsingPlugin enables a plugin for use in the current test case

func (*SynchronousMessageWithPlugin) WithContents

func (s *SynchronousMessageWithPlugin) WithContents(contents string, contentType string) *SynchronousMessageWithPluginContents

type SynchronousMessageWithPluginContents

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

func (*SynchronousMessageWithPluginContents) ExecuteTest

func (m *SynchronousMessageWithPluginContents) ExecuteTest(t *testing.T, integrationTest func(m SynchronousMessage) error) error

ExecuteTest runs the current test case against a Mock Service. Will cleanup interactions between tests within a suite and write the pact file if successful

func (*SynchronousMessageWithPluginContents) StartTransport

func (s *SynchronousMessageWithPluginContents) StartTransport(transport string, address string, config map[string][]interface{}) *SynchronousMessageWithTransport

type SynchronousMessageWithRequest

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

func (*SynchronousMessageWithRequest) WithResponse

AddMessage creates a new asynchronous consumer expectation

type SynchronousMessageWithRequestBuilder

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

func (*SynchronousMessageWithRequestBuilder) WithContent

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

func (*SynchronousMessageWithRequestBuilder) WithJSONContent

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

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

func (*SynchronousMessageWithRequestBuilder) WithMetadata

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

type SynchronousMessageWithResponse

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

func (*SynchronousMessageWithResponse) ExecuteTest

func (m *SynchronousMessageWithResponse) ExecuteTest(t *testing.T, integrationTest func(md SynchronousMessage) error) error

ExecuteTest runs the current test case against a Mock Service. Will cleanup interactions between tests within a suite and write the pact file if successful

type SynchronousMessageWithResponseBuilder

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

func (*SynchronousMessageWithResponseBuilder) WithContent

WithContent specifies the payload in bytes that the consumer expects to receive May be called multiple times, with each call appeding a new response to the interaction

func (*SynchronousMessageWithResponseBuilder) WithJSONContent

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

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

func (*SynchronousMessageWithResponseBuilder) WithMetadata

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

type SynchronousMessageWithTransport

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

func (*SynchronousMessageWithTransport) ExecuteTest

func (s *SynchronousMessageWithTransport) ExecuteTest(t *testing.T, integrationTest func(tc TransportConfig, m SynchronousMessage) error) error

type SynchronousPact

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

func NewSynchronousPact

func NewSynchronousPact(config Config) (*SynchronousPact, error)

func (*SynchronousPact) AddSynchronousMessage

func (m *SynchronousPact) AddSynchronousMessage(description string) *UnconfiguredSynchronousMessageBuilder

type TransportConfig

type TransportConfig struct {
	Port    int
	Address string
}

type UnconfiguredAsynchronousMessageBuilder

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

func (*UnconfiguredAsynchronousMessageBuilder) UsingPlugin

UsingPlugin enables a plugin for use in the current test case

func (*UnconfiguredAsynchronousMessageBuilder) WithContent

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

func (*UnconfiguredAsynchronousMessageBuilder) WithJSONContent

func (m *UnconfiguredAsynchronousMessageBuilder) WithJSONContent(content interface{}) *AsynchronousMessageWithContents

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

func (*UnconfiguredAsynchronousMessageBuilder) WithMetadata

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

type UnconfiguredSynchronousMessageBuilder

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

func (*UnconfiguredSynchronousMessageBuilder) Given

Given specifies a provider state

func (*UnconfiguredSynchronousMessageBuilder) GivenWithParameter

Given specifies a provider state

func (*UnconfiguredSynchronousMessageBuilder) UsingPlugin

UsingPlugin enables a plugin for use in the current test case

func (*UnconfiguredSynchronousMessageBuilder) WithRequest

AddMessage creates a new asynchronous consumer expectation

Jump to

Keyboard shortcuts

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