Skip to content

Commit

Permalink
chore: do not write empty matching rules to the Pact file
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Aug 27, 2024
1 parent 791db1f commit 9cc38a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rust/pact_models/src/matchingrules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,12 @@ impl MatchingRules {
map.insert(name.to_string(), rules.to_v3_json());
}
_ => {
map.insert(name.to_string(), sub_category.to_v3_json());
let value = sub_category.to_v3_json();
if let Some(values) = value.as_object() {
if !values.is_empty() {
map.insert(name.to_string(), value);
}
}
}
}
map
Expand Down Expand Up @@ -1922,7 +1927,8 @@ mod tests {
"header" => {
"item1" => [ MatchingRule::Regex("5".to_string()) ],
"$['principal_identifier[account_id]']" => [ MatchingRule::Regex("\\w+".to_string()) ]
}
},
"metadata" => {}
};
}

Expand Down

0 comments on commit 9cc38a2

Please sign in to comment.