pacttesting

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPact added in v1.3.0

func AddPact(filename string) error

AddPact loads a pact definition from a file and ensures that stub servers are running.

func AddPactInteraction added in v1.3.0

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 added in v1.3.0

func EnsurePactRunning(provider, consumer string) string

func IntegrationTest

func IntegrationTest(pactFilePaths []Pact, testFunc func(), retryOptions ...retry.RetryOption)

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 added in v1.3.0

func ResetPacts()

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

func TestWithStubServices(pactFilePaths []Pact, testFunc func())

Runs testFunc with stub services defined by given pacts. Does not verify that the stubs are called

func VerifyAll added in v1.0.3

func VerifyAll() error

func VerifyInteractions added in v1.3.0

func VerifyInteractions(provider, consumer string, retryOptions ...retry.RetryOption) error

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
	BaseURL  string
	Consumer string
	Provider string
	Pid      int
	Running  bool `json:"-"`
}

func (*MockServer) AddInteraction

func (m *MockServer) AddInteraction(interaction interface{}) error

func (*MockServer) DeleteInteractions

func (m *MockServer) DeleteInteractions() error

func (*MockServer) Stop added in v1.4.0

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 Pact

type Pact = string

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

func NewPactFile(data []byte) (*PactFile, error)

NewPactFile create new PACT file representation

func (*PactFile) Split

func (f *PactFile) Split() *[]*PactFile

Split divides bulk file with many interactions to single-interaction PACT files. It's required as a workaround to make bigger PACT test runs working.

type PactProviderTestParams

type PactProviderTestParams struct {
	Pacts                 string
	AuthToken             string
	BaseURL               string
	ProviderStateSetupURL string
	Testing               *testing.T
}

type PactRequestMatchingFilter added in v1.0.2

type PactRequestMatchingFilter = func(map[string]interface{})

Jump to

Keyboard shortcuts

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