fix(testing): make test provider context-aware for goroutine#470
fix(testing): make test provider context-aware for goroutine#470
Conversation
Summary of ChangesHello @erka, 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 refines the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #470 +/- ##
==========================================
- Coverage 83.21% 82.65% -0.57%
==========================================
Files 27 27
Lines 2109 2127 +18
==========================================
+ Hits 1755 1758 +3
- Misses 305 311 +6
- Partials 49 58 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request makes the TestProvider context-aware, which is a great improvement for writing tests with goroutines. The implementation correctly uses context.Context to pass test-specific data, and maintains backward compatibility with the previous goroutine-local storage mechanism. The addition of automatic cleanup via t.Cleanup is also a nice touch for usability. I have a couple of suggestions to improve the documentation and fix a minor typo.
| // testFrameworkWithContext is an optional interface for tests that can provide | ||
| // a context, enabling context-aware evaluation when flags are used across goroutines. | ||
| type testFrameworkWithContext interface { |
There was a problem hiding this comment.
what's the purpose of this secondary interface? why not just update TestFramework to contain Context() context.Context? it'd be much simpler that way...
for that matter, why not use testing.TB instead? the TestFramework interface seems like an unnecessary abstraction.
There was a problem hiding this comment.
I would love to use testing.TB, but there will likely be someone who doesn’t use it in a specific case, and their tests or code might fail. Since go-sdk is already at v1, that could make people unhappy. So I work around...
Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
| // | ||
| if ctx == nil { | ||
| ctx = context.Background() | ||
| } |
There was a problem hiding this comment.
I think we can remove this. If ctx is nil here, then it's a programmer error that would be masked by silent substitution with context.Background().
This PR
Related issues
closes #436