From fe4409e37f083a630725d246e36808b776c223c7 Mon Sep 17 00:00:00 2001 From: Reuven Date: Sat, 8 Jan 2022 23:06:59 +0200 Subject: [PATCH] fixed tests --- diff/required_diff.go | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/diff/required_diff.go b/diff/required_diff.go index 31c6d6d8..bd2fc443 100644 --- a/diff/required_diff.go +++ b/diff/required_diff.go @@ -1,8 +1,17 @@ package diff -// RequiredPropertiesDiff describes the changes between a pair of lists of Required Properties +// RequiredPropertiesDiff describes the changes between a pair of lists of required properties type RequiredPropertiesDiff struct { - *StringsDiff + StringsDiff +} + +// Empty indicates whether a change was found in this element +func (diff *RequiredPropertiesDiff) Empty() bool { + if diff == nil { + return true + } + + return diff.StringsDiff.Empty() } func (diff *RequiredPropertiesDiff) removeNonBreaking() { @@ -10,13 +19,16 @@ func (diff *RequiredPropertiesDiff) removeNonBreaking() { return } + if diff.StringsDiff.Empty() { + return + } + diff.Deleted = nil } func getRequiredPropertiesDiff(config *Config, strings1, strings2 StringList) *RequiredPropertiesDiff { - diff := &RequiredPropertiesDiff{ - StringsDiff: getStringsDiff(strings1, strings2), - } + + diff := getRequiredPropertiesDiffInternal(strings1, strings2) if config.BreakingOnly { diff.removeNonBreaking() @@ -28,3 +40,12 @@ func getRequiredPropertiesDiff(config *Config, strings1, strings2 StringList) *R return diff } + +func getRequiredPropertiesDiffInternal(strings1, strings2 StringList) *RequiredPropertiesDiff { + if stringsDiff := getStringsDiff(strings1, strings2); stringsDiff != nil { + return &RequiredPropertiesDiff{ + StringsDiff: *stringsDiff, + } + } + return nil +}