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