Skip to content

Commit 572819d

Browse files
authored
Merge pull request #5565 from killianmuldoon/tests/fix-matchers-bug
🐛 Fix Matchers bug on ignored paths and add tests
2 parents 1b2a319 + f117a6c commit 572819d

File tree

2 files changed

+503
-6
lines changed

2 files changed

+503
-6
lines changed

internal/matchers/matchers.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,13 @@ func (m *Matcher) calculateDiff(actual interface{}) ([]byte, error) {
126126
}
127127

128128
// Use a mergePatch to produce a diff between the two objects.
129-
originalWithModifiedJSON, err := jsonpatch.MergePatch(originalJSON, actualJSON)
130-
if err != nil {
131-
return nil, err
132-
}
133-
rawDiff, err := jsonpatch.CreateMergePatch(originalJSON, originalWithModifiedJSON)
129+
diff, err := jsonpatch.CreateMergePatch(originalJSON, actualJSON)
134130
if err != nil {
135131
return nil, err
136132
}
137133

138134
// Filter the diff according to the rules attached to the Matcher.
139-
diff, err := filterDiff(rawDiff, m.options.allowPaths, m.options.ignorePaths)
135+
diff, err = filterDiff(diff, m.options.allowPaths, m.options.ignorePaths)
140136
if err != nil {
141137
return nil, err
142138
}

0 commit comments

Comments
 (0)