-
-
Notifications
You must be signed in to change notification settings - Fork 173
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 support for disabling repeat notifications if the values haven't changed #547
Conversation
webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go
Outdated
Show resolved
Hide resolved
@AnalogJ - would you mind reviewing before I update the 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.
Fantastic PR! 🥳 thanks for making such a meaningful contribution.
I like the idea, and the implementation. Anything that touches the notification system needs alot of tests (which you mentioned you're working on).
I also called out that I'd like to see some more comments in the filtering logic as well.
Thanks again!
webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go
Outdated
Show resolved
Hide resolved
webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go
Outdated
Show resolved
Hide resolved
webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go
Outdated
Show resolved
Hide resolved
webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go
Outdated
Show resolved
Hide resolved
Addressed the comments and tested the image (it works). Will add/fix tests |
@AnalogJ - I started looking into the tests, but I got stuck pretty quickly because I am a total golang noob. The main issue is that I need to pass a Thanks! |
Bump. Pinging @AnalogJ for some help with tests. Thanks! |
I was going to say that it's super easy, but it seems like I forgot to generate a mock for the database. Let me generate one and push to your branch |
So I added a new file: webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go You can now use that to mock the database in your tests (similar to what I do with the Config mock): //setup
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_config.NewMockDeviceRepo(mockCtrl)
// mock/fake out data and calls to the `fakeDatabase`, providing expected arguments and expected return parameters.
// you can mock any function in the interface: https://github.com/kaysond/scrutiny/blob/master/webapp/backend/pkg/database/interface.go
fakeDatabase.EXPECT().GetDevices(context.Background()).Return([]models.Device{}, nil).AnyTimes()
// if your inputs vary, you can use `gomock.Any()` as the argument
fakeDatabase.EXPECT().HealthCheck(gomock.Any()).Return(fmt.Errorf("my error").AnyTimes()
// once you finish setting up the mock, you can then pass it into your function under test:
ShouldNotify(... , fakeDatabase)
// and internally when it calls `deviceRepo.GetSmartAttributeHistory(...)`, you can fake the response data. |
you should be good to write tests now @kaysond |
Thank you! I'll take a crack at it tonight if I can. |
* Add a new database function for getting the tail * Update ShouldNotify() to handle ignoring repeat notifications if set
@AnalogJ fixed the existing tests and added a few more for the case where repeat notifications are turned off. Looking at the updated |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #547 +/- ##
==========================================
- Coverage 32.54% 30.34% -2.21%
==========================================
Files 54 28 -26
Lines 3045 2755 -290
Branches 66 0 -66
==========================================
- Hits 991 836 -155
+ Misses 2018 1889 -129
+ Partials 36 30 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Bump. Pinging @AnalogJ for review |
hey @kaysond apologies for the delay. |
will do! |
fixes #504
fixes #364
fixes #514
related #553
Still needs testing and some refactoring