Skip to content

Commit e2d2ca3

Browse files
committed
fix: compatibility-suite was failing after upgrading pact_matching to 2.0.1
1 parent 4d7f186 commit e2d2ca3

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

compatibility-suite/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ async-trait = "0.1.74"
99
base64 = "0.22.0"
1010
bytes = "1.5.0"
1111
cucumber = "0.21.1"
12-
futures = "0.3.29"
1312
itertools = "0.14.0"
1413
lazy_static = "1.4.0"
1514
maplit = "1.0.2"
1615
pact_models = { version = "~1.3.6" }
17-
pact_matching = { version = "2.0.0-beta.3" }
18-
pact_mock_server = { version = "=2.1.2" }
16+
pact_matching = { version = "~2.0.1" }
17+
pact_mock_server = { version = "~2.1.2" }
1918
pact_verifier = { version = "~1.3.2" }
2019
pact_consumer = { version = "~1.4.1" }
21-
pretty_assertions = "1.4.0"
2220
regex = "1.10.2"
2321
reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "json"] }
2422
rocket = { version = "0.5.0", features = ["json"] }
@@ -31,7 +29,8 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter", "tracing-lo
3129
uuid = { version = "1.5.0", features = ["v4"] }
3230

3331
[patch.crates-io]
34-
pact_matching = { version = "2.0.0-beta.3", git = "http://github.com/pact-foundation/pact-reference", tag = "libpact_matching-v2.0.0-beta.3" }
32+
pact_models = { version = "1.3.6", path = "../rust/pact_models" }
33+
pact_matching = { version = "2.0.1", path = "../rust/pact_matching" }
3534

3635
[[test]]
3736
name = "v1_consumer"

compatibility-suite/tests/v4_steps/http_matching.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::fs::File;
22
use std::io::BufReader;
3+
34
use anyhow::anyhow;
45
use cucumber::gherkin::Step;
56
use cucumber::{given, then, when};
@@ -11,8 +12,8 @@ use pact_models::v4::http_parts::{HttpRequest, HttpResponse};
1112
use pact_models::v4::synch_http::SynchronousHttp;
1213
use serde_json::{json, Value};
1314
use pact_matching::{match_request, match_response, Mismatch};
14-
use crate::shared_steps::setup_body;
1515

16+
use crate::shared_steps::setup_body;
1617
use crate::v4_steps::V4World;
1718

1819
#[given("an expected response configured with the following:")]
@@ -58,11 +59,13 @@ fn a_status_response_is_received(world: &mut V4World, status: u16) {
5859
}
5960

6061
#[when("the response is compared to the expected one")]
61-
async fn the_response_is_compared_to_the_expected_one(world: &mut V4World) {
62-
world.response_results.extend(match_response(world.expected_response.clone(),
63-
world.received_responses.first().unwrap().clone(), &world.pact.boxed(), &SynchronousHttp::default().boxed())
64-
.await
65-
)
62+
async fn the_response_is_compared_to_the_expected_one(world: &mut V4World) -> anyhow::Result<()> {
63+
world.response_results.extend(match_response(world.expected_response.clone(),
64+
world.received_responses.first().unwrap().clone(), &world.pact.boxed(),
65+
&SynchronousHttp::default().boxed())
66+
.await?
67+
);
68+
Ok(())
6669
}
6770

6871
#[then("the response comparison should be OK")]

rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/pact_matching/src/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl DoMatch<&Value> for MatchingRule {
271271
_ => Err(anyhow!("Expected {} ({}) to match a boolean", value_of(actual_value), type_of(actual_value)))
272272
}
273273
MatchingRule::NotEmpty => match actual_value {
274-
Value::Null => Err(anyhow!("Expected non-empty but got a NULL")),
274+
Value::Null => Err(anyhow!("Expected non-empty value but got a NULL")),
275275
Value::String(s) => if s.is_empty() {
276276
Err(anyhow!("Expected '' (String) to not be empty"))
277277
} else {

rust/pact_matching/src/matchingrules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ pub fn compare_lists_with_matchingrule<T: Display + Debug + PartialEq + Clone +
14631463
result.extend(match_list_contents(path, expected, actual, context.as_ref(), callback));
14641464
}
14651465
_ => {
1466-
if let Err(mismatch) = expected.matches_with(actual, rule, cascaded) {
1466+
if let Err(mismatch) = rule.match_value(expected, actual, cascaded, true) {
14671467
result.push(CommonMismatch {
14681468
path: path.to_string(),
14691469
expected: expected.for_mismatch(),

0 commit comments

Comments
 (0)