-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
🌱 (chore): prevent variable shadowing in DecodePluginConfig test to ensure accurate assertion #4711
🌱 (chore): prevent variable shadowing in DecodePluginConfig test to ensure accurate assertion #4711
Conversation
Hi @kersten. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
pkg/config/v3/config_test.go
Outdated
var pluginCfg PluginConfig | ||
err := c0.DecodePluginConfig(key, &pluginCfg) | ||
var decodedPluginCfg PluginConfig | ||
err := c0.DecodePluginConfig(key, &decodedPluginCfg) | ||
Expect(err).To(HaveOccurred()) | ||
Expect(errors.As(err, &config.PluginKeyNotFoundError{})).To(BeTrue()) |
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.
Please Consider using the gomega's MatchError
matcher.
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.
@nunnatsa You're absolutely right - this should be addressed. I'd prefer to keep it out of scope for this PR though, as it's unrelated to the main change. There are a few places in the codebase where errors.As
is used in the tests, so it would make sense to handle all of them together in a separate PR. WDYT?
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've open another PR for it here: #4723
pkg/config/v3/config_test.go
Outdated
var pluginCfg PluginConfig | ||
err := c1.DecodePluginConfig("plugin-y", &pluginCfg) | ||
var decodedPluginCfg PluginConfig | ||
err := c1.DecodePluginConfig("plugin-y", &decodedPluginCfg) | ||
Expect(err).To(HaveOccurred()) | ||
Expect(errors.As(err, &config.PluginKeyNotFoundError{})).To(BeTrue()) |
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.
Same
/test macos-latest |
@kersten: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
26c8f93
to
82fdfd7
Compare
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
82fdfd7
to
4fe3c28
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kersten The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
🌱 (chore): DecodePluginConfig test variable reuse
This PR fixes potential shadowing in table-driven tests by renaming
pluginCfg
todecodedPluginCfg
. This avoids confusion between the decoded result and the expected struct, ensuring the assertions are valid and that Gomega receives the correct references.This improves test clarity and avoids subtle bugs due to variable reuse within closures.