[−][src]Crate pact_mock_server
The pact_mock_server
crate provides the in-process mock server for mocking HTTP requests
and generating responses based on a pact file. It implements the V3 Pact specification
(https://github.com/pact-foundation/pact-specification/tree/version-3).
The exported functions using C bindings for controlling the mock server now live in the pact_mock_server_ffi
crate.
Modules
matching | The matching module defines how a request is matched against a list of potential interactions. |
mock_server | This module defines the external interface for controlling one particular instance of a mock server. |
server_manager | This module defines a manager for holding multiple instances of mock servers. |
tls | TLS support structs |
Structs
MANAGER | A global thread-safe, "init-on-demand" reference to a server manager. When the server manager is initialized, it starts a separate thread on which to serve requests. |
Enums
MockServerError | Mock server errors |
WritePactFileErr | Write Pact File Errors |
Functions
create_mock_server | Creates a mock server. Requires the pact JSON as a string as well as the port for the mock server to run on. A value of 0 for the port will result in a port being allocated by the operating system. The port of the mock server is returned. |
create_tls_mock_server | Creates a TLS mock server. Requires the pact JSON as a string as well as the port for the mock server to run on. A value of 0 for the port will result in a port being allocated by the operating system. The port of the mock server is returned. |
mock_server_matched | Function to check if a mock server has matched all its requests. The port number is passed in, and if all requests have been matched, true is returned. False is returned if there is no mock server on the given port, or if any request has not been successfully matched. |
mock_server_mismatches | Gets all the mismatches from a mock server. The port number of the mock server is passed in, and the results are returned in JSON format as a String. |
shutdown_mock_server | Shuts down the mock server with the provided port. Returns a boolean value to indicate if the mock server was successfully shut down. |
start_mock_server | Starts a mock server with the given ID, pact and port number. The ID needs to be unique. A port
number of 0 will result in an auto-allocated port by the operating system. Returns the port
that the mock server is running on wrapped in a |
start_mock_server_with_config | Starts a mock server with the given ID, pact and port number. The ID needs to be unique. A port
number of 0 will result in an auto-allocated port by the operating system. Returns the port
that the mock server is running on wrapped in a |
start_tls_mock_server | Starts a TLS mock server with the given ID, pact and port number. The ID needs to be unique. A port
number of 0 will result in an auto-allocated port by the operating system. Returns the port
that the mock server is running on wrapped in a |
start_tls_mock_server_with_config | Starts a TLS mock server with the given ID, pact and port number. The ID needs to be unique. A port
number of 0 will result in an auto-allocated port by the operating system. Returns the port
that the mock server is running on wrapped in a |
write_pact_file | Trigger a mock server to write out its pact file. This function should
be called if all the consumer tests have passed. The directory to write the file to is passed
as the second parameter. If |