-
Notifications
You must be signed in to change notification settings - Fork 310
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
Refactor generate_queries devops case to use errs #77
Refactor generate_queries devops case to use errs #77
Conversation
Codecov Report
@@ Coverage Diff @@
## master #77 +/- ##
==========================================
- Coverage 57.13% 56.82% -0.32%
==========================================
Files 76 76
Lines 3719 3757 +38
==========================================
+ Hits 2125 2135 +10
- Misses 1570 1592 +22
- Partials 24 30 +6
Continue to review full report at Codecov.
|
@@ -40,9 +39,6 @@ const ( | |||
LabelHighCPU = "high-cpu" | |||
) | |||
|
|||
// for ease of testing |
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 must admit, I did find this ironic when I first read it 😄
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.
yeah enjoyed a nice chuckle as I removed it
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 this!
I wanted to do it myself but decided to finish up the current PR that I had in line before doing that.
Previously the devops use case generation code used a call to log.Fatalf when something went wrong. This makes it awkward to test error conditions when generating queries from other packages, since we need a way to (a) replace the unexported call to log.Fatalf and (b) prevent the runtime from actually quitting. It is better for the library to actually return errors on calls that can fail, rather than either fataling or panicking. Now other packages can handle the errors themselves and also test error conditions in their packages as well. This refactor was pruned a bit to bubble the 'panic' up one level for now. When the actual generation code encounters the error during normal execution, it will panic. But these are easier to test for and don't require adding hooks to replace the 'fatal' path in the original package.
70ddcb7
to
3ba75f6
Compare
Previously the devops use case generation code used a call to
log.Fatalf when something went wrong. This makes it awkward to test
error conditions when generating queries from other packages, since
we need a way to (a) replace the unexported call to log.Fatalf and
(b) prevent the runtime from actually quitting.
It is better for the library to actually return errors on calls
that can fail, rather than either fataling or panicking. Now other
packages can handle the errors themselves and also test error
conditions in their packages as well.
This refactor was pruned a bit to bubble the 'panic' up one level
for now. When the actual generation code encounters the error
during normal execution, it will panic. But these are easier to
test for and don't require adding hooks to replace the 'fatal'
path in the original package.