From cb06065945ff5f8bb1c6a6e59ad6266d470a4e99 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 4 Feb 2025 09:53:11 +1100 Subject: [PATCH] chore: add small timeout to test --- rust/pact_matching/src/tests.rs | 4 ++-- rust/pact_verifier/src/pact_broker.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rust/pact_matching/src/tests.rs b/rust/pact_matching/src/tests.rs index 1f5ffbcf..7a91f44e 100644 --- a/rust/pact_matching/src/tests.rs +++ b/rust/pact_matching/src/tests.rs @@ -660,8 +660,8 @@ async fn body_matching_with_number_matchers() { let matching_context = CoreMatchingContext::new(DiffConfig::AllowUnexpectedKeys, &category, &hashmap!{}); - // let result = match_body(&expected, &actual, &matching_context, &CoreMatchingContext::default()).await; - // expect!(result.mismatches().iter()).to(be_empty()); + let result = match_body(&expected, &actual, &matching_context, &CoreMatchingContext::default()).await; + expect!(result.mismatches().iter()).to(be_empty()); let result2 = match_body(&expected, &actual2, &matching_context, &CoreMatchingContext::default()).await; assert_ne!(result2.mismatches(), vec![]); diff --git a/rust/pact_verifier/src/pact_broker.rs b/rust/pact_verifier/src/pact_broker.rs index e50e5e17..36603b15 100644 --- a/rust/pact_verifier/src/pact_broker.rs +++ b/rust/pact_verifier/src/pact_broker.rs @@ -1170,12 +1170,14 @@ pub struct PactVerificationProperties { #[cfg(test)] mod tests { + use std::time::Duration; use expectest::expect; use expectest::prelude::*; use pact_models::{Consumer, PactSpecification, Provider}; use pact_models::prelude::RequestResponsePact; use pact_models::sync_interaction::RequestResponseInteraction; use pretty_assertions::assert_eq; + use tokio::time::sleep; use pact_consumer::mock_server::StartMockServerAsync; use pact_consumer::prelude::*; @@ -1376,6 +1378,9 @@ mod tests { let client = HALClient::with_url(pact_broker.url().as_str(), None); let expected_requests = client.retries as usize; let result = client.post_json(pact_broker.url().as_str(), "{}").await; + + sleep(Duration::from_millis(100)).await; + expect!(result.clone()).to(be_err()); expect!(pact_broker.metrics().requests).to(be_equal_to(expected_requests )); }