Skip to content

Commit

Permalink
Handle None in schema equiv for attribtues and member-of (#480)
Browse files Browse the repository at this point in the history
Signed-off-by: John Kastner <[email protected]>
  • Loading branch information
john-h-kastner-aws authored Nov 20, 2024
1 parent 5eb1d90 commit b511731
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cedar-drt/fuzz/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,15 @@ impl TypeName for InternalName {

impl<N: PartialEq + Debug + Display + Clone + TypeName + Ord> Equiv for json_schema::ActionType<N> {
fn equiv(lhs: &Self, rhs: &Self) -> Result<(), String> {
if &lhs.attributes != &rhs.attributes {
if &lhs.attributes != &rhs.attributes
&& !(lhs.attributes.as_ref().is_none_or(HashMap::is_empty)
&& rhs.attributes.as_ref().is_none_or(HashMap::is_empty))
{
Err(format!("Attributes don't match"))
} else if &lhs.member_of != &rhs.member_of {
} else if &lhs.member_of != &rhs.member_of
&& !(lhs.member_of.as_ref().is_none_or(Vec::is_empty)
&& rhs.member_of.as_ref().is_none_or(Vec::is_empty))
{
Err(format!("Member-of doesn't match"))
} else {
match (&lhs.applies_to, &rhs.applies_to) {
Expand Down

0 comments on commit b511731

Please sign in to comment.