1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use async_trait::async_trait;
use pact_models::pact::Pact;
use pact_models::sync_pact::RequestResponsePact;
use url::Url;
use pact_mock_server::matching::MatchResult;
use pact_mock_server::mock_server::MockServerMetrics;
use crate::mock_server::http_mock_server::ValidatingHttpMockServer;
pub(crate) mod http_mock_server;
pub(crate) mod plugin_mock_server;
pub trait ValidatingMockServer {
fn url(&self) -> Url;
fn path(&self, path: &str) -> Url;
fn status(&self) -> Vec<MatchResult>;
fn metrics(&self) -> MockServerMetrics;
}
#[async_trait]
pub trait StartMockServer {
fn start_mock_server(&self, catalog_entry: Option<&str>) -> Box<dyn ValidatingMockServer>;
async fn start_mock_server_async(&self, catalog_entry: Option<&str>) -> Box<dyn ValidatingMockServer>;
}
#[async_trait]
impl StartMockServer for RequestResponsePact {
fn start_mock_server(&self, _catalog_entry: Option<&str>) -> Box<dyn ValidatingMockServer> {
ValidatingHttpMockServer::start(self.boxed(), None)
}
async fn start_mock_server_async(&self, _catalog_entry: Option<&str>) -> Box<dyn ValidatingMockServer> {
ValidatingHttpMockServer::start_async(self.boxed(), None).await
}
}