Skip to content

Commit

Permalink
Merge pull request #5565 from killianmuldoon/tests/fix-matchers-bug
Browse files Browse the repository at this point in the history
🐛  Fix Matchers bug on ignored paths and add tests
  • Loading branch information
k8s-ci-robot authored Nov 4, 2021
2 parents 1b2a319 + f117a6c commit 572819d
Show file tree
Hide file tree
Showing 2 changed files with 503 additions and 6 deletions.
8 changes: 2 additions & 6 deletions internal/matchers/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,13 @@ func (m *Matcher) calculateDiff(actual interface{}) ([]byte, error) {
}

// Use a mergePatch to produce a diff between the two objects.
originalWithModifiedJSON, err := jsonpatch.MergePatch(originalJSON, actualJSON)
if err != nil {
return nil, err
}
rawDiff, err := jsonpatch.CreateMergePatch(originalJSON, originalWithModifiedJSON)
diff, err := jsonpatch.CreateMergePatch(originalJSON, actualJSON)
if err != nil {
return nil, err
}

// Filter the diff according to the rules attached to the Matcher.
diff, err := filterDiff(rawDiff, m.options.allowPaths, m.options.ignorePaths)
diff, err = filterDiff(diff, m.options.allowPaths, m.options.ignorePaths)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 572819d

Please sign in to comment.