🪞 [MIRRORED] test: add unit tests for duplicate secret reuse scenario#2274
🪞 [MIRRORED] test: add unit tests for duplicate secret reuse scenario#2274infernus01 wants to merge 1 commit intomainfrom
Conversation
Signed-off-by: ab-ghosh <abghosh@redhat.com>
Summary of ChangesHello @infernus01, 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 enhances the test suite for the Highlights
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
|
🔍 PR Lint Feedback
|
There was a problem hiding this comment.
Code Review
This pull request adds unit tests for handling secret creation failures, specifically for scenarios where a secret already exists or a generic creation error occurs. The changes are well-implemented, and the new tests correctly cover the intended logic. I have one suggestion to refactor a small piece of duplicated code in the test setup to improve maintainability.
| var k8int kubeinteraction.Interface | ||
| if tt.secretCreationError != nil { | ||
| k8int = &KinterfaceTestWithError{ | ||
| KinterfaceTest: kitesthelper.KinterfaceTest{ | ||
| ConsoleURL: "https://console.url", | ||
| ExpectedNumberofCleanups: tt.expectedNumberofCleanups, | ||
| GetSecretResult: secrets, | ||
| }, | ||
| CreateSecretError: tt.secretCreationError, | ||
| } | ||
| } else { | ||
| k8int = &kitesthelper.KinterfaceTest{ | ||
| ConsoleURL: "https://console.url", | ||
| ExpectedNumberofCleanups: tt.expectedNumberofCleanups, | ||
| GetSecretResult: secrets, | ||
| } | ||
| } |
There was a problem hiding this comment.
To improve maintainability and reduce code duplication, you can refactor this block. You can initialize the base kitesthelper.KinterfaceTest once, and then conditionally wrap it with KinterfaceTestWithError if an error needs to be injected. This avoids repeating the initialization logic.
ktest := &kitesthelper.KinterfaceTest{
ConsoleURL: "https://console.url",
ExpectedNumberofCleanups: tt.expectedNumberofCleanups,
GetSecretResult: secrets,
}
var k8int kubeinteraction.Interface = ktest
if tt.secretCreationError != nil {
k8int = &KinterfaceTestWithError{
KinterfaceTest: *ktest,
CreateSecretError: tt.secretCreationError,
}
}
📝 Description of the Change
🔄 Mirrors #2273 to run E2E tests. Original author: @ab-ghosh
👨🏻 Linked Jira
🔗 Linked GitHub Issue
Fixes #
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com
**💡You can use the script
./hack/add-llm-coauthor.shto automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.