Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Jan 8, 2022
1 parent 4d4259f commit fe4409e
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions diff/required_diff.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
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() {
if diff.Empty() {
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()
Expand All @@ -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
}

0 comments on commit fe4409e

Please sign in to comment.