Refactored Apply test

This commit is contained in:
Juan Fernandez
2023-07-07 08:51:51 -04:00
parent 38661ad7b0
commit 8a1ffc97ea
3 changed files with 69 additions and 58 deletions
+25
View File
@@ -230,3 +230,28 @@ func formatListDiff(listA, listB interface{}, extraA, extraB []interface{}) stri
return msg.String()
}
// QueryElementsMatch asserts that two queries slices match
func QueryElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
t.Helper()
opt := cmp.FilterPath(func(p cmp.Path) bool {
for _, ps := range p {
switch ps := ps.(type) {
case cmp.StructField:
switch ps.Name() {
case "ID",
"UpdateCreateTimestamps",
"AuthorID",
"AuthorName",
"AuthorEmail",
"Packs",
"Saved":
return true
}
}
}
return false
}, cmp.Ignore())
return ElementsMatchWithOptions(t, listA, listB, []cmp.Option{opt}, msgAndArgs)
}