From 712bc797ecbd3bbf843c1d6ae97b57d2981f5cbb Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Sun, 18 Feb 2024 03:54:56 +1100 Subject: [PATCH] chore: update examples in matchers to JSON test --- rust/pact_models/src/matchingrules/mod.rs | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/rust/pact_models/src/matchingrules/mod.rs b/rust/pact_models/src/matchingrules/mod.rs index 2461907ad..e8d48a1f8 100644 --- a/rust/pact_models/src/matchingrules/mod.rs +++ b/rust/pact_models/src/matchingrules/mod.rs @@ -1890,30 +1890,39 @@ mod tests { }, "path" => { "" => [ MatchingRule::Regex("/path/\\d+".to_string()) ] }, "query" => { - "a" => [ MatchingRule::Regex("\\w+".to_string()) ] + "a" => [ MatchingRule::Regex("\\w+".to_string()) ], + "$['principal_identifier[account_id]']" => [ MatchingRule::Regex("\\w+".to_string()) ] }, "header" => { - "item1" => [ MatchingRule::Regex("5".to_string()) ] + "item1" => [ MatchingRule::Regex("5".to_string()) ], + "$['principal_identifier[account_id]']" => [ MatchingRule::Regex("\\w+".to_string()) ] } }; } it "generates V2 matcher format" { - expect!(matchers.to_v2_json().to_string()).to(be_equal_to( + pretty_assertions::assert_eq!(matchers.to_v2_json().to_string(), "{\"$.body.a.b\":{\"match\":\"type\"},\ \"$.header.item1\":{\"match\":\"regex\",\"regex\":\"5\"},\ + \"$.header['principal_identifier[account_id]']\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"},\ \"$.path\":{\"match\":\"regex\",\"regex\":\"/path/\\\\d+\"},\ - \"$.query.a\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"}}" - )); + \"$.query.a\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"},\ + \"$.query['principal_identifier[account_id]']\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"}\ + }" + ); } it "generates V3 matcher format" { - expect!(matchers.to_v3_json().to_string()).to(be_equal_to( + pretty_assertions::assert_eq!(matchers.to_v3_json().to_string(), "{\"body\":{\"$.a.b\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"type\"}]}},\ - \"header\":{\"item1\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"5\"}]}},\ + \"header\":{\"item1\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"5\"}]},\ + \"principal_identifier[account_id]\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"\\\\w+\"}]}\ + },\ \"path\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"/path/\\\\d+\"}]},\ - \"query\":{\"a\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"\\\\w+\"}]}}}" - )); + \"query\":{\"a\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"\\\\w+\"}]},\ + \"principal_identifier[account_id]\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"\\\\w+\"}]}\ + }}" + ); } } }