-
Notifications
You must be signed in to change notification settings - Fork 9
test: Write test for OpenfeatureAPI to return No-op client when OpenfeatureClient is unresolvable #157
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: Write test for OpenfeatureAPI to return No-op client when OpenfeatureClient is unresolvable #157
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.
Summary of Changes
Hello @Tmakinde, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request refactors the client creation logic within the OpenFeature API to enhance testability and robustness. It introduces a dedicated method for resolving clients, which allows for better handling of failure scenarios by returning a NoOpClient. This change is supported by a new testing dependency that enables mocking of final classes, ensuring comprehensive test coverage for these new behaviors.
Highlights
- New Dependency for Testing: The dg/bypass-finals library has been added to composer.json to facilitate testing of final classes.
- Client Resolution Refactoring: A new resolveClient method was introduced in OpenFeatureAPI.php to centralize the creation of OpenFeatureClient instances, improving modularity and testability.
- Enhanced Client Error Handling Test: A new unit test was added to OpenFeatureAPITest.php to ensure that a NoOpClient is returned when the client resolution process encounters an exception, leveraging the new dg/bypass-finals dependency for mocking.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
============================================
+ Coverage 95.19% 96.75% +1.56%
- Complexity 227 228 +1
============================================
Files 40 40
Lines 583 586 +3
============================================
+ Hits 555 567 +12
+ Misses 28 19 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Code Review
This pull request introduces a refactoring to extract client creation into a dedicated resolveClient method within OpenFeatureAPI, and adds a new test case to ensure a NoOpClient is returned if client resolution fails. The changes improve testability. My review includes a few suggestions:
- The implementation to return a
NoOpClienton failure is missing in thegetClientmethod's error handling, which will cause the new test to fail. - The visibility of the new
resolveClientmethod could be restricted for better encapsulation. - There's a minor correction needed in a test file's type hint.
Overall, this is a good step towards making the client resolution more robust, and with the suggested changes, it will be complete.
tcarrio
left a comment
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.
A styling issue, and one necessary change, granted mockery should support it. Otherwise, this looks good to me. Once the changes are pushed, I can approve.
Thank you for your contribution @Tmakinde 🙏
88e3496 to
427c078
Compare
427c078 to
6399754
Compare
Signed-off-by: tmakinde <makindet74@gmail.com>
Signed-off-by: tmakinde <makindet74@gmail.com>
…atureClient fail Signed-off-by: tmakinde <makindet74@gmail.com>
6399754 to
72d8848
Compare
Overview
This pull request refactors the client creation logic in
OpenFeatureAPIto improve testability and resilience.Introduces a dedicated
resolveClientmethod, which encapsulates client instantiation logic.Ensures that failures during client resolution are handled gracefully by returning a
NoOpClient.Adds a testing dependency to allow mocking of final classes, enabling comprehensive test coverage without altering production code.