chore(cmd): refactored main program#26
Conversation
Another baby step forward: * refactored error and flags handling in main program * this improves testability, so we add a unit test for main There is still some room for improvement (coverage, I/O injection for better control in a test environment). Essential options in main are covered by tests. Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
Pull Request Test Coverage Report for Build 19666678257Details
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR refactors the main program to improve testability by extracting error handling and flag management into testable functions. The changes introduce a commandContext struct to hold CLI flags and I/O streams, an execute() function that can be independently tested, and comprehensive unit tests covering the main execution paths.
Key changes:
- Extracted main logic into testable
execute()function with dependency injection for I/O - Introduced
commandContextandcommandFlagsstructs for better organization - Added comprehensive unit tests for main program execution paths
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| cmd/go-ctrf-json-reporter/main.go | Refactored main program with extracted execute(), registerFlags(), and ctrfEnvFromFlags() functions; introduced structs for better organization |
| cmd/go-ctrf-json-reporter/main_test.go | Added comprehensive unit tests for main execution with various flag combinations |
| cmd/go-ctrf-json-reporter/testdata/test.json | Added test fixture containing sample Go test JSON output for testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
Will correct the few little things reporter by copilot later this week. |
5aaebe1 to
542df34
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
542df34 to
7ac356c
Compare
|
Thanks! |
Another baby step forward:
There is still some room for improvement (coverage, I/O injection for better control in a test environment). Essential options in main are covered by tests.