-
Notifications
You must be signed in to change notification settings - Fork 8
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
test: add missing unit test #51
Conversation
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.
Nice work, your coding style is clean and I like that you've used table driven testing.
notify/metricslog_test.go
Outdated
}{ | ||
{ | ||
name: "Remove 3 oldest samples", | ||
log: &MetricsLog{path: "/tmp/test_log"}, |
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.
As all of these tests are executed in sequence this will work just fine.
If you want to ensure that the same tmp file isn't used in other tests that might lead to flanky test results you can use ioutils.tempFile
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.
For this usecase it might be good to use t.TempDir
https://pkg.go.dev/testing#B.TempDir as it is used e.g. in function createMetricsPath
- or use this function.
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.
Thanks for the feedback. I think that's a good suggestion for this usecase tried updating the code, it's a little cleaner now too!
b03c4cc
to
af4802e
Compare
Add table-driven unit test for removeOldestSample function Signed-off-by: ccowman <[email protected]>
🎉 This PR is included in version 1.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Add table-driven unit test for removeOldestSample function