pact_plugin_driver/mock_server.rs
1//! Module to support dealing with mock servers from plugins
2
3use std::path::PathBuf;
4
5use crate::content::ContentMismatch;
6use crate::plugin_models::PactPlugin;
7
8/// Mock server configuration
9#[derive(Debug, Default, Clone)]
10pub struct MockServerConfig {
11 /// Output path to generate Pact files to. Defaults to the current working directory.
12 pub output_path: Option<PathBuf>,
13 /// Host interface to use to bind to. Defaults to the loopback adapter.
14 pub host_interface: Option<String>,
15 /// Port to bind to. Default (or a value of 0) get the OS to open a random port
16 pub port: u32,
17 /// If TLS should be used (if supported by the mock server)
18 pub tls: bool
19}
20
21/// Details of the running mock server
22#[derive(Debug, Clone)]
23pub struct MockServerDetails {
24 /// Unique key for the mock server
25 pub key: String,
26 /// Base URL to the running mock server
27 pub base_url: String,
28 /// Port the mock server is running on
29 pub port: u32,
30 /// Plugin the mock server belongs to
31 pub plugin: PactPlugin
32}
33
34/// Results from the mock server
35#[derive(Debug, Default, Clone)]
36pub struct MockServerResults {
37 /// service + method that was requested
38 pub path: String,
39 /// If an error occurred trying to handle the request
40 pub error: String,
41 /// Any mismatches that occurred
42 pub mismatches: Vec<ContentMismatch>
43}