I believe I'm almost there:
```#[test_log::test(tokio::test)]
async fn when_instrument_state_switched_to_starting_up_then_example_unit_starts_up_itself() {
// Arrange
let provider = PactBuilder::new_v4("instrument-state-unit", "example-unit")
.interaction("Instrument State changes to Starting Up and triggers units to startup", "", |mut i| {
i.test_name("test_unit_reacts_to_instrument_state_starting_up");
i.request.content_type("application/json");
i.request.json_body(json_pattern!({
"origin": like!("simulated-instrument-sn555"),
"version": like!("1.0.0"),
"name": like!("InstrumentStateChanged"),
"old_state": like!("PoweredOff"),
"new_state": like!("StartingUp")
}));
i.response.ok().content_type("application/json").json_body(json_pattern!({
"result": "hello"
}));
i
}).start_mock_server(None);
let provider_info = ProviderInfo {
name: "example-unit".to_string(),
host: provider.url().host_str().unwrap().to_string(),
transports: vec![ ProviderTransport {
transport: "HTTP".to_string(),
port: provider.url().port(),
path: None,
scheme: Some("http".to_string())
} ],
.. ProviderInfo::default()
};
// Create the pact source to pull pacts from the pact-broker
let pact_source = PactSource::BrokerUrl("example-unit".to_string(), "
http://localhost:9292".to_string(), None, vec![]);
// Arrange
let verification_options: VerificationOptions<NullRequestFilterExecutor> = VerificationOptions::default();
let provider_state_executor = Arc::new(DummyProviderStateExecutor{});
let publish_options = PublishOptions {
provider_version: Some("1.0.0".to_string()),
build_url: None,
provider_tags: vec![],
provider_branch: None,
};
let result = verify_provider_async(
provider_info,
vec![ pact_source ],
FilterInfo::None,
vec![ "instrument-state-unit".to_string() ],
&verification_options,
Some(&publish_options),
&provider_state_executor,
None
).await;
// Assert
expect!(result.unwrap().result).to(be_true());
}```
The results of it is:
> Failures:
>
> 1) Verifying a pact between instrument-state-unit and example-unit Given Unit is powered off And Hardware units works normally - Instrument State changes to Starting Up and triggers units to startup - error sending request for url (
http://127.0.0.1:8080/)
>
> 2) Verifying a pact between instrument-state-unit and example-unit - Unit State Changed to StartingUp - error sending request for url (
http://127.0.0.1:8080/)
>
> 3) Verifying a pact between instrument-state-unit and example-unit Given Unit is powered off And Hardware units works normally - Unit State Changed to StartingUp - error sending request for url (
http://127.0.0.1:8080/)
>
>
> There were 3 pact failures
So I could:
1. create a rust test that pulls the consumer pacts from a running pact-broker
2. Creates a MockServer (which seems to be now the source of the problem)
3. Provide dummy state data
The issue is that the error message is quite unspecific. Any idea what could be the issue?