Crates.io | pact_mock_server |
lib.rs | pact_mock_server |
version | 2.0.0-beta.5 |
source | src |
created_at | 2016-06-01 11:43:30.070989 |
updated_at | 2024-07-02 06:13:43.991094 |
description | Pact-Rust support library that implements in process mock server |
homepage | https://www.pact.io |
repository | https://github.com/pact-foundation/pact-core-mock-server/tree/main/pact_mock_server |
max_upload_size | |
id | 5256 |
size | 197,351 |
This library implements the in-process mock server for matching HTTP requests and generating responses from a pact file. It implements the V3 Pact specification and V4 Pact specification.
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.
Simple function that returns a boolean value given the port number of the mock service. This value will be true if all the expectations of the pact that the mock server was created with have been met. It will return false if any request did not match, an un-recognised request was received or an expected request was not received.
This returns all the mismatches, un-expected requests and missing requests in JSON format, given the port number of the 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.
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 None is passed in, the current working directory is used. If overwrite is true, the file will be overwritten with the contents of the current pact. Otherwise it will be merged with any existing pact file.
Returns Ok if the pact file was successfully written. Returns an Err if the file can not be written, or there is no mock server running on that port.
All features are enabled by default
datetime
: Enables support of date and time expressions and generators.xml
: Enables support for parsing XML documents.plugins
: Enables support for using plugins.multipart
: Enables support for MIME multipart bodies.tls
: Enables support for mock servers using TLS. This will add the following dependencies: hyper-rustls, rustls, rustls-pemfile, tokio-rustls.