-
Notifications
You must be signed in to change notification settings - Fork 50
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
tests: improve test coverage for main packages #1010
Conversation
This is hard to explain, but... it's a trick to be able to exercise the main function from within tests without the logic defaulting to starting the client and ultimately failing because there's no socket to connect to. Because `os.Args[0]` is occupied by the Go test runner we can't alter it, so defaulting to starting the daemon is the next best thing.
We can do a smoke test of the main function by telling it to print the version and asserting on the output.
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.
Excellent work as usual :)
2 small questions before approving it.
Remove environment prefix since we never used it and it's not documented anywhere, and use decorate to bind the viper flags.
Similarly to how we handle adsysd and adwatchd, handle the Cobra configuration in a separate package that we call from the main package, thus leaving the main package unaware of implementation details.
These tests also cover the commands package as we exercise the main function directly.
This is no longer needed after the admxgen refactor.
275424a
to
561487d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1010 +/- ##
==========================================
+ Coverage 91.40% 93.35% +1.94%
==========================================
Files 78 79 +1
Lines 6890 6877 -13
==========================================
+ Hits 6298 6420 +122
+ Misses 581 447 -134
+ Partials 11 10 -1 ☔ View full report in Codecov by Sentry. |
I've added details in the individual commit messages, but ultimately this aims to improve coverage for lacking packages such as all main packages for the CLI tools (adsysd/adsysctl, adwatchd, admxgen).
Fixes UDENG-2762