Documentation ¶
Index ¶
- func AddPact(filename string) error
- func AddPactInteraction(provider, consumer string, interaction *dsl.Interaction) error
- func EnsurePactRunning(provider, consumer string) string
- func IntegrationTest(pactFilePaths []Pact, testFunc func(), retryOptions ...retry.Option) error
- func PreassignPorts(pactFilePaths []Pact)
- func ResetPacts()
- func RunIntegrationTest(t *testing.T, pactFilePaths []Pact, testFunc func(), ...) error
- func SplitPactBulkFile(bulkFilePath string, outputDirPath string, ...) error
- func StopMockServers()
- func TestWithStubServices(pactFilePaths []Pact, testFunc func()) error
- func VerifyAll() error
- func VerifyInteractions(provider, consumer string, retryOptions ...retry.Option) error
- func VerifyMessageProviderRaw(params PactProviderTestParams, request dsl.VerifyMessageRequest) ([]types.ProviderVerifierResponse, error)
- func VerifyProviderMessagingPacts(params PactProviderTestParams, messageProducers dsl.MessageHandlers)
- func VerifyProviderPacts(params PactProviderTestParams)
- type MockServer
- type Pact
- type PactFile
- type PactProviderTestParams
- type PactRequestMatchingFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPact ¶
AddPact loads a pact definition from a file and ensures that stub servers are running.
func AddPactInteraction ¶
func AddPactInteraction(provider, consumer string, interaction *dsl.Interaction) error
AddPactInteraction ensures that a stub server is running for the provided provider/consumer and returns an interaction to be configured
func EnsurePactRunning ¶
func IntegrationTest ¶
Runs mock services defined by the given pacts, invokes testFunc then verifies that the pacts have been invoked successfully
func PreassignPorts ¶
func PreassignPorts(pactFilePaths []Pact)
PreassignPorts sets a random port for all future mocked instances and configures viper to point to them. This is necessary to get viper configuration before actually loading pact files. This function can be called multiple times for the same files, it will only initialise them once.
func ResetPacts ¶
func ResetPacts()
func RunIntegrationTest ¶ added in v2.1.5
func RunIntegrationTest(t *testing.T, pactFilePaths []Pact, testFunc func(), retryOptions ...retry.Option) error
Runs mock services defined by the given pacts, invokes testFunc then verifies that the pacts have been invoked successfully
func SplitPactBulkFile ¶
func SplitPactBulkFile(bulkFilePath string, outputDirPath string, requestFilters ...PactRequestMatchingFilter) error
SplitPactBulkFile reads bulk PACT files, splits it into smaller ones and writes output to destination directory
func StopMockServers ¶
func StopMockServers()
func TestWithStubServices ¶
TestWithStubServices runs testFunc with stub services defined by given pacts. Does not verify that the stubs are called
func VerifyInteractions ¶
func VerifyMessageProviderRaw ¶
func VerifyMessageProviderRaw( params PactProviderTestParams, request dsl.VerifyMessageRequest, ) ([]types.ProviderVerifierResponse, error)
VerifyMessageProviderRaw runs provider message verification.
func VerifyProviderMessagingPacts ¶
func VerifyProviderMessagingPacts(params PactProviderTestParams, messageProducers dsl.MessageHandlers)
func VerifyProviderPacts ¶
func VerifyProviderPacts(params PactProviderTestParams)
Types ¶
type MockServer ¶
type MockServer struct { Port int `json:"port"` BaseURL string `json:"base_url"` Consumer string `json:"consumer"` Provider string `json:"provider"` Pid int `json:"pid"` Running bool `json:"-"` }
func (*MockServer) AddInteraction ¶
func (m *MockServer) AddInteraction(interaction interface{}) error
func (*MockServer) DeleteInteractions ¶
func (m *MockServer) DeleteInteractions() error
func (*MockServer) Stop ¶
func (m *MockServer) Stop() error
Stop gracefully shuts does the underlying pact-mock-service process and removes the server metadata (pid) file.
func (*MockServer) Verify ¶
func (m *MockServer) Verify() error
type PactFile ¶
type PactFile struct { Provider struct { Name string `json:"name"` } `json:"provider"` Consumer struct { Name string `json:"name"` } `json:"consumer"` Interactions []struct { Description string `json:"description"` ProviderStates interface{} `json:"providerStates"` Request interface{} `json:"request"` Response interface{} `json:"response"` } `json:"interactions"` Metadata interface{} `json:"metadata"` }
PactFile describes expectations between provider and consumer
func NewPactFile ¶
NewPactFile create new PACT file representation
type PactProviderTestParams ¶
type PactRequestMatchingFilter ¶
type PactRequestMatchingFilter = func(map[string]interface{})