-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add regexTitle Filter #94
Conversation
alxndr13
commented
Nov 1, 2023
- fix: better error handling in the transformerfactory
- fix: better error handling in the filterfactory
- fix: add new filter 'regexTitle'
- test: add test for 'regexTitle' filter
- test: add test for 'allDayEvents' filter
- test: add test for 'declinedEvents' filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are pretty repetitive, please add a helper function to at least partially deduplicate the code.
internal/filter/regexTitle_test.go
Outdated
|
||
filteredEvents := []models.Event{} | ||
|
||
for _, event := range sourceEvents { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract that loop into a separate helper function together with the assert below. Then use that helper in all relevant tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, had to add a "MockInterface" of the Filter Interface to prevent having an import loop. Is there an easier way to achieve this?
left the assert outside of the helper func, may want to use different asserts for different test cases in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the FilterEvents
helper into a filter_test
package.
The alternative would be to somehow break the Filter
interface out of the sync
package, but I don't see an easy way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the FilterEvents helper into a filter_test package.
That's what I did first, dismissed it as I thought introducing another package is not that clean 😂
Thanks!
The alternative would be to somehow break the Filter interface out of the sync package, but I don't see an easy way.
Yup, thought about this as well. Maybe we have to work on the whole code structure again, maybe I'll do that on a snowy winter day. But for now, this looks good.
This allows removing MockFilter interface without causing an import loop.
3a63c60
to
29ee397
Compare
29ee397
to
458eb22
Compare
@alxndr13 You've removed the last few commits which I had pushed 😕 . I guess that wasn't intended? |
@MichaelEischer damn, yup. that wasn't intended. sorry. Do you still have the commits locally? 😞 |
458eb22
to
29ee397
Compare
Yep, I've force pushed them :-) |
Now we should be good to go then :) |