Pact C++ Consumer DSL  0.0.7
DSL to support writing consumer tests in C++
Public Member Functions | Public Attributes | List of all members
pact_consumer::Interaction Class Reference

#include <consumer.h>

Public Member Functions

 Interaction (const Pact *parent, const char *description)
 
Interaction given (const char *provider_state) const
 
Interaction given (const char *provider_state, const std::unordered_map< std::string, std::string > &parameters) const
 
Interaction uponReceiving (const char *description) const
 
Interaction withRequest (const char *method, const char *path) const
 
Interaction withQuery (const std::unordered_map< std::string, std::vector< std::string >> &query) const
 
Interaction withHeaders (const std::unordered_map< std::string, std::vector< std::string >> &headers) const
 
Interaction withBody (const std::string &body, const std::string &content_type) const
 
Interaction withJsonBody (pact_consumer::matchers::IMatcher::Ptr body) const
 
Interaction withBinaryFile (const std::string &content_type, const std::filesystem::path &example_file) const
 
Interaction withMultipartFileUpload (const std::string &part_name, const std::string &content_type, const std::filesystem::path &example_file) const
 
Interaction willRespondWith (size_t status) const
 
Interaction withResponseHeaders (const std::unordered_map< std::string, std::vector< std::string >> &headers) const
 
Interaction withResponseBody (const std::string &body, const std::string &content_type) const
 
Interaction withResponseJsonBody (pact_consumer::matchers::IMatcher::Ptr body) const
 
Interaction withResponseBinaryFile (const std::string &content_type, const std::filesystem::path &example_file) const
 
Interaction withResponseMultipartFileUpload (const std::string &part_name, const std::string &content_type, const std::filesystem::path &example_file) const
 

Public Attributes

InteractionHandle interaction
 

Detailed Description

Class that defines an interaction between a consumer and provider

Constructor & Destructor Documentation

◆ Interaction()

pact_consumer::Interaction::Interaction ( const Pact parent,
const char *  description 
)

Member Function Documentation

◆ given() [1/2]

Interaction pact_consumer::Interaction::given ( const char *  provider_state) const

Adds the provider state to the interaction

◆ given() [2/2]

Interaction pact_consumer::Interaction::given ( const char *  provider_state,
const std::unordered_map< std::string, std::string > &  parameters 
) const

Adds a provider state with parameters

◆ uponReceiving()

Interaction pact_consumer::Interaction::uponReceiving ( const char *  description) const

Sets the description for the interaction

◆ willRespondWith()

Interaction pact_consumer::Interaction::willRespondWith ( size_t  status) const

Sets the status code for the response

◆ withBinaryFile()

Interaction pact_consumer::Interaction::withBinaryFile ( const std::string &  content_type,
const std::filesystem::path &  example_file 
) const

Sets the body for the request using the example file and content type. Note that this will attempt to load the entire example file in memory. Use small files for your testing.

◆ withBody()

Interaction pact_consumer::Interaction::withBody ( const std::string &  body,
const std::string &  content_type 
) const

Sets the body for the request to the string contents.

◆ withHeaders()

Interaction pact_consumer::Interaction::withHeaders ( const std::unordered_map< std::string, std::vector< std::string >> &  headers) const

Sets the headers for the request

◆ withJsonBody()

Interaction pact_consumer::Interaction::withJsonBody ( pact_consumer::matchers::IMatcher::Ptr  body) const

Sets the body for the request using the provided body template.

◆ withMultipartFileUpload()

Interaction pact_consumer::Interaction::withMultipartFileUpload ( const std::string &  part_name,
const std::string &  content_type,
const std::filesystem::path &  example_file 
) const

Sets the body for the request as a MIME multipart body using the example file and content type. Note that this will attempt to load the entire example file in memory. Use small files for your testing.

◆ withQuery()

Interaction pact_consumer::Interaction::withQuery ( const std::unordered_map< std::string, std::vector< std::string >> &  query) const

Sets the query parameters for the request

◆ withRequest()

Interaction pact_consumer::Interaction::withRequest ( const char *  method,
const char *  path 
) const

Sets the method and path for the request

◆ withResponseBinaryFile()

Interaction pact_consumer::Interaction::withResponseBinaryFile ( const std::string &  content_type,
const std::filesystem::path &  example_file 
) const

Sets the body for the response using the example file and content type. Note that this will attempt to load the entire example file in memory. Use small files for your testing.

◆ withResponseBody()

Interaction pact_consumer::Interaction::withResponseBody ( const std::string &  body,
const std::string &  content_type 
) const

Sets the body for the response to the string contents.

◆ withResponseHeaders()

Interaction pact_consumer::Interaction::withResponseHeaders ( const std::unordered_map< std::string, std::vector< std::string >> &  headers) const

Sets the headers for the response

◆ withResponseJsonBody()

Interaction pact_consumer::Interaction::withResponseJsonBody ( pact_consumer::matchers::IMatcher::Ptr  body) const

Sets the body for the request using the provided body template

◆ withResponseMultipartFileUpload()

Interaction pact_consumer::Interaction::withResponseMultipartFileUpload ( const std::string &  part_name,
const std::string &  content_type,
const std::filesystem::path &  example_file 
) const

Sets the body for the response as a MIME multipart body using the example file and content type. Note that this will attempt to load the entire example file in memory. Use small files for your testing.

Member Data Documentation

◆ interaction

InteractionHandle pact_consumer::Interaction::interaction

The documentation for this class was generated from the following files: