From 0f5f563fb8f8a94bf5927c77e920e89626b39869 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Fri, 19 Jan 2024 14:41:37 +1100 Subject: [PATCH] fix: regression - prevous matching rules change broke specification tests #359 --- rust/pact_models/src/matchingrules/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/pact_models/src/matchingrules/mod.rs b/rust/pact_models/src/matchingrules/mod.rs index 16b525590..ab9acbe09 100644 --- a/rust/pact_models/src/matchingrules/mod.rs +++ b/rust/pact_models/src/matchingrules/mod.rs @@ -979,7 +979,7 @@ impl MatchingRuleCategory { self.add_rule_list(DocPath::empty(), rules)?; } else if self.name == Category::QUERY || self.name == Category::HEADER { for (k, v) in m { - let mut path = DocPath::empty(); + let mut path = DocPath::root(); path.push_field(k); self.add_rule_list(path, v)?; } @@ -1824,11 +1824,11 @@ mod tests { })); expect!(matching_rules.rules_for_category("query")).to(be_some().value(MatchingRuleCategory { name: "query".into(), - rules: hashmap!{ DocPath::empty().join("Q1") => RuleList { rules: vec![ MatchingRule::Regex("\\d+".to_string()) ], rule_logic: RuleLogic::And, cascaded: false } } + rules: hashmap!{ DocPath::root().join("Q1") => RuleList { rules: vec![ MatchingRule::Regex("\\d+".to_string()) ], rule_logic: RuleLogic::And, cascaded: false } } })); expect!(matching_rules.rules_for_category("header")).to(be_some().value(MatchingRuleCategory { name: "header".into(), - rules: hashmap!{ DocPath::empty().join("HEADERY") => RuleList { rules: vec![ + rules: hashmap!{ DocPath::root().join("HEADERY") => RuleList { rules: vec![ MatchingRule::Include("ValueA".to_string()), MatchingRule::Include("ValueB".to_string()) ], rule_logic: RuleLogic::Or, cascaded: false } } })); @@ -1933,11 +1933,11 @@ mod tests { })); expect!(matching_rules.rules_for_category("query")).to(be_some().value(MatchingRuleCategory { name: "query".into(), - rules: hashmap!{ DocPath::empty().join("Q[]") => RuleList { rules: vec![ MatchingRule::Regex("\\d+".to_string()) ], rule_logic: RuleLogic::And, cascaded: false } } + rules: hashmap!{ DocPath::root().join("Q[]") => RuleList { rules: vec![ MatchingRule::Regex("\\d+".to_string()) ], rule_logic: RuleLogic::And, cascaded: false } } })); expect!(matching_rules.rules_for_category("header")).to(be_some().value(MatchingRuleCategory { name: "header".into(), - rules: hashmap!{ DocPath::empty().join("Y[]") => RuleList { rules: vec![ + rules: hashmap!{ DocPath::root().join("Y[]") => RuleList { rules: vec![ MatchingRule::Include("ValueA".to_string()), MatchingRule::Include("ValueB".to_string()) ], rule_logic: RuleLogic::Or, cascaded: false } } }));