types

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 7 Imported by: 24

Documentation

Overview

Package types contains a number of structs common to the library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandResponse

type CommandResponse struct {
	// System exit code from the command. Note that this will only even be 0 or 1.
	ExitCode int

	// Error message (if any) from the command.
	Message string
}

CommandResponse contains the exit status and any message from running an external command / service.

type ConsumerVersionSelector added in v1.2.0

type ConsumerVersionSelector struct {
	Pacticipant        string `json:"-"` // Deprecated
	All                bool   `json:"-"` // Deprecated
	Version            string `json:"-"` // Deprecated
	Tag                string `json:"tag,omitempty"`
	FallbackTag        string `json:"fallbackTag,omitempty"`
	Latest             bool   `json:"latest,omitempty"`
	Consumer           string `json:"consumer,omitempty"`
	DeployedOrReleased bool   `json:"deployedOrReleased,omitempty"`
	Deployed           bool   `json:"deployed,omitempty"`
	Released           bool   `json:"released,omitempty"`
	Environment        string `json:"environment,omitempty"`
	MainBranch         bool   `json:"mainBranch,omitempty"`
	Branch             string `json:"branch,omitempty"`
	MatchingBranch     bool   `json:"matchingBranch,omitempty"`
}

ConsumerVersionSelector are the way we specify which pacticipants and versions we want to use when configuring verifications See https://docs.pact.io/selectors for more

func (*ConsumerVersionSelector) Validate added in v1.2.0

func (c *ConsumerVersionSelector) Validate() error

Validate the selector configuration

type Hook added in v1.0.0

type Hook func() error

Hook functions are used to tap into the lifecycle of a Consumer or Provider test

type MockServer added in v0.0.2

type MockServer struct {
	Pid   int
	Port  int
	Error error
	Args  []string
}

MockServer contains the RPC client interface to a Mock Server

type PactMessageRequest added in v1.0.0

type PactMessageRequest struct {

	// Message is the object to be marshalled to JSON
	Message interface{}

	// Consumer is the name of the message consumer
	Consumer string

	// Provider is the name of the message provider
	Provider string

	// PactDir is the location of where pacts should be stored
	PactDir string

	// Args are the arguments sent to to the message service
	Args []string
}

PactMessageRequest contains the response from the Pact Message CLI execution.

func (*PactMessageRequest) Validate added in v1.0.0

func (m *PactMessageRequest) Validate() error

Validate checks all things are well and constructs the CLI args to the message service

type PactReificationRequest added in v1.0.0

type PactReificationRequest struct {

	// Message is the object to be marshalled to JSON
	Message interface{}

	// Args are the arguments sent to to the message service
	Args []string
}

PactReificationRequest contains the response from the Pact Message CLI execution.

func (*PactReificationRequest) Validate added in v1.0.0

func (m *PactReificationRequest) Validate() error

Validate checks all things are well and constructs the CLI args to the message service

type ProviderState added in v0.0.2

type ProviderState struct {
	Consumer string   `json:"consumer"`
	State    string   `json:"state"`
	States   []string `json:"states"`
}

ProviderState Models a provider state coming over the Wire. This is generally provided as a request to an HTTP endpoint (e.g. PUT /state) to configure a state on a Provider.

type ProviderStates added in v0.0.2

type ProviderStates map[string][]string

ProviderStates is a mapping of consumers to all known states. This is usually a response from an HTTP endpoint (e.g. GET /states) to find all states a provider has.

type ProviderVerifierResponse added in v0.0.10

type ProviderVerifierResponse struct {
	Version  string `json:"version"`
	Examples []struct {
		ID              string      `json:"id"`
		Description     string      `json:"description"`
		FullDescription string      `json:"full_description"`
		Status          string      `json:"status"`
		FilePath        string      `json:"file_path"`
		LineNumber      int         `json:"line_number"`
		RunTime         float64     `json:"run_time"`
		PendingMessage  interface{} `json:"pending_message"`
		Mismatches      []string    `json:"mismatches"`
		Pact            struct {
			ConsumerName     string `json:"consumer_name"`
			ProviderName     string `json:"provider_name"`
			URL              string `json:"url"`
			ShortDescription string `json:"short_description"`
		} `json:"pact"`
		Exception struct {
			Class     string   `json:"class"`
			Message   string   `json:"message"`
			Backtrace []string `json:"backtrace"`
		} `json:"exception,omitempty"`
	} `json:"examples"`
	Summary struct {
		Duration                     float64 `json:"duration"`
		ExampleCount                 int     `json:"example_count"`
		FailureCount                 int     `json:"failure_count"`
		PendingCount                 int     `json:"pending_count"`
		ErrorsOutsideOfExamplesCount int     `json:"errors_outside_of_examples_count"`
		Notices                      []struct {
			Text string `json:"text"`
			When string `json:"when"`
		} `json:"notices"`
	} `json:"summary"`
	SummaryLine string `json:"summary_line"`
}

ProviderVerifierResponse contains the output of the pact-provider-verifier command.

type PublishRequest

type PublishRequest struct {
	// Array of local Pact files or directories containing them. Required.
	PactURLs []string

	// URL to fetch the provider states for the given provider API. Optional.
	PactBroker string

	// Username for Pact Broker basic authentication. Optional
	BrokerUsername string

	// Password for Pact Broker basic authentication. Optional
	BrokerPassword string

	// BrokerToken is required when authenticating using the Bearer token mechanism
	BrokerToken string

	// ConsumerVersion is the semantical version of the consumer API.
	ConsumerVersion string

	// Tags help you organise your Pacts for different testing purposes.
	// e.g. "production", "master" and "development" are some common examples.
	Tags []string

	// Branches are used to identify which pacts a provider should verify using
	// consumer version selectors, associating the consumer API version with
	// a branch. This supersedes tags. https://docs.pact.io/pact_broker/branches
	Branch string

	// Verbose increases verbosity of output
	// Deprecated
	Verbose bool

	// Arguments to the VerificationProvider
	// Deprecated: This will be deleted after the native library replaces Ruby deps.
	Args []string
}

PublishRequest contains the details required to Publish Pacts to a broker.

func (*PublishRequest) Validate added in v1.0.0

func (p *PublishRequest) Validate() error

Validate checks that the minimum fields are provided. Deprecated: This map be deleted after the native library replaces Ruby deps, and should not be used outside of this library.

type ReificationResponse added in v1.0.0

type ReificationResponse struct {
	// Interface wrapped object
	Response interface{}

	// Raw response from reification
	ResponseRaw []byte
}

ReificationResponse contains the output of the reification request

type State added in v1.0.0

type State struct {
	Name string `json:"name"`
}

State specifies how the system should be configured when verified. e.g. "user A exists"

type StateHandler added in v1.0.0

type StateHandler func() error

StateHandler is a provider function that sets up a given state before the provider interaction is validated

type StateHandlers added in v1.0.0

type StateHandlers map[string]StateHandler

StateHandlers is a list of StateHandler's

type VerifyRequest

type VerifyRequest struct {
	// URL to hit during provider verification.
	ProviderBaseURL string

	// Local/HTTP paths to Pact files.
	// NOTE: if specified alongside BrokerURL it will run the verification once for
	// each dynamic pact (Broker) discovered and user specified (URL) pact.
	PactURLs []string

	// Pact Broker URL for broker-based verification
	// NOTE: if specified alongside PactURLs it will run the verification once for
	// each dynamic pact (Broker) discovered and user specified (URL) pact.
	BrokerURL string

	// Selectors are the way we specify which pacticipants and
	// versions we want to use when configuring verifications
	// See https://docs.pact.io/selectors for more
	ConsumerVersionSelectors []ConsumerVersionSelector

	// Retrieve the latest pacts with this consumer version tag
	Tags []string

	// Tags to apply to the provider application version
	ProviderTags []string

	// Branch to apply to the provider application version
	ProviderBranch string

	// ProviderStatesSetupURL is the endpoint to post current provider state
	// to on the Provider API.
	// Deprecated: For backward compatibility ProviderStatesSetupURL is
	// still supported. Use StateHandlers instead.
	ProviderStatesSetupURL string

	// Provider is the name of the Providing service.
	Provider string

	// Username when authenticating to a Pact Broker.
	BrokerUsername string

	// Password when authenticating to a Pact Broker.
	BrokerPassword string

	// BrokerToken is required when authenticating using the Bearer token mechanism
	BrokerToken string

	// FailIfNoPactsFound configures the framework to return an error
	// if no pacts were found when looking up from a broker
	FailIfNoPactsFound bool

	// PublishVerificationResults to the Pact Broker.
	PublishVerificationResults bool

	// ProviderVersion is the semantical version of the Provider API.
	ProviderVersion string

	// CustomProviderHeaders are headers to add during pact verification `requests`.
	// eg 'Authorization: Basic cGFjdDpwYWN0'.
	//
	// NOTE: Use this feature very carefully, as anything in here is not captured
	// in the contract (e.g. time-bound tokens)
	//
	// NOTE: This should be used very carefully and deliberately, as anything you do here
	// runs the risk of changing the contract and breaking the real system.
	CustomProviderHeaders []string

	// StateHandlers contain a mapped list of message states to functions
	// that are used to setup a given provider state prior to the message
	// verification step.
	StateHandlers StateHandlers

	// BeforeEach allows you to configure your provider prior to the individual test execution
	// e.g. setup temporary tokens, prepare data
	BeforeEach Hook

	// AfterEach allows you to configure your provider prior to the test execution
	// e.g. reset the database state
	AfterEach Hook

	// RequestFilter is a piece of middleware that will intercept requests/responses
	// from the provider in order to modify it. This is useful in situations where
	// you need to override a value due to time sensitivity - such as a OAuth Bearer
	// token.
	// NOTE: This should be used very carefully and deliberately, as anything you do here
	// runs the risk of changing the contract and breaking the real system.
	RequestFilter proxy.Middleware

	// Custom TLS Configuration to use when making the requests to/from
	// the Provider API. Useful for setting custom certificates, MASSL etc.
	CustomTLSConfig *tls.Config

	// Allow pending pacts to be included in verification (see pact.io/pending)
	EnablePending bool

	// Pull in new WIP pacts from _any_ tag (see pact.io/wip)
	IncludeWIPPactsSince *time.Time

	// Specify an output directory to log all of the verification request/responses
	// seen by the verification process. Useful to debug issues with your contract
	// and API
	PactLogDir string

	// Specify the log verbosity of the CLI verifier process spawned through verification
	// Useful for debugging issues with the framework itself
	PactLogLevel string

	// Verbose increases verbosity of output
	// Deprecated
	Verbose bool

	// Tag the provider with the current git branch in the Pact Broker
	TagWithGitBranch bool

	// Arguments to the VerificationProvider
	// Deprecated: This will be deleted after the native library replaces Ruby deps.
	Args []string
}

VerifyRequest configures the pact verification process.

func (*VerifyRequest) Validate

func (v *VerifyRequest) Validate() error

Validate checks that the minimum fields are provided. Deprecated: This map be deleted after the native library replaces Ruby deps, and should not be used outside of this library.

Jump to

Keyboard shortcuts

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