-
Notifications
You must be signed in to change notification settings - Fork 116
test: add unit tests for StartPR #2298
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
base: main
Are you sure you want to change the base?
test: add unit tests for StartPR #2298
Conversation
Summary of ChangesHello @theakshaypant, 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 significantly enhances the test coverage 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
|
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 comprehensive suite of unit tests for the startPR function in a new pipelineascode_startpr_test.go file. The tests are well-structured, covering a wide range of success, failure, and concurrency scenarios, which significantly improves the robustness and maintainability of the startPR logic. The changes also include refactoring some test helper code into the new file, which is a good cleanup. I've found a couple of minor issues in a test setup that could be improved for clarity.
|
a lot of those fakes are already provided in pkg/test/ and i believe a lot of those unittests are covered in https://github.com/openshift-pipelines/pipelines-as-code/blob/6c646e453/pkg/pipelineascode/pipelineascode_test.go isnt it ? |
Wanted to put this in draft. Haven't cleaned up the redundant tests yet. |
0c0a38b to
c2eb052
Compare
|
/gemini review |
1 similar comment
|
/gemini review |
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 comprehensive suite of unit tests for the startPR function in a new pipelineascode_startpr_test.go file. This is an excellent addition that significantly improves test coverage for this critical functionality. The changes also include refactoring the existing pipelineascode_test.go to remove tests that are now covered in the new file, which is a good cleanup.
My review focuses on improving the maintainability and clarity of the newly added tests. I've identified a few areas where the tests can be made more readable and robust, such as reducing repetitive setup code, clarifying the intent of some tests, and simplifying complex test logic. Overall, this is a high-quality contribution.
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 comprehensive suite of unit tests for the startPR function, significantly improving test coverage and code reliability. The refactoring of existing tests into a new, dedicated file (pipelineascode_startpr_test.go) is a great organizational improvement. The tests are well-structured, covering a wide range of success paths, error conditions, and concurrency scenarios. I've included a few suggestions to further enhance the new test suite by reducing redundancy and improving clarity. Overall, this is a high-quality contribution.
0d61aee to
72dc237
Compare
|
/gemini review |
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 new test file, pipelineascode_startpr_test.go, to provide comprehensive unit test coverage for the StartPR functionality. The changes also include modifications to pipelineascode_test.go and kubernetesint.go to support the new tests. I have identified some areas where improvements can be made to enhance the code's robustness and clarity.
| func (k *KinterfaceTestWithSecretTracking) CreateSecret(ctx context.Context, ns string, secret *corev1.Secret) error { | ||
| // Atomically increment and get the new count | ||
| count := k.secretCreationCount.Add(1) | ||
|
|
||
| // First creation succeeds, subsequent ones return AlreadyExists to simulate race condition | ||
| if count > 1 { | ||
| return errors.NewAlreadyExists(schema.GroupResource{Group: "", Resource: "secrets"}, secret.GetName()) | ||
| } |
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.
72dc237 to
3d3528c
Compare
|
I see that you have created multiple funcs for every scenario can you please make them in one func like we usually do in PaC |
Add comprehensive unit test coverage for StartPR functionality in new pipelineascode_startpr_test.go file. Signed-off-by: Akshay Pant <[email protected]> Co-authored-by: Claude-4.5-Sonnet (via Cursor)
3d3528c to
554009e
Compare
| test func(t *testing.T) | ||
| }{ | ||
| { | ||
| name: "success - comprehensive success test covering the full startPR flow", |
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.
This is a very weird way to do testcases, you redoing the testing constructions all the time.. it's not supposed to work like that
|
This look a bit vibe coded, which is fine, no problem with that... but you may need to be careful to make sure it output the code the same way as what we have before.. (which is again fine, you just need to know how the project structure works to be able to drive the LLM to output things as expected) |
Yes, tried to restructure the tests into a single one using Cursor. Have gone through the individual cases in detail though. |
|
@chmouel @zakisk How do we feel about going back to a previous version of these tests where we have multiple test funcs? Given the amount of functionality covered in startPR, I feel it would be a bit hard to consolidate all the scenarios into a single table driven test func. For your reference, the test funcs earlier were the following with fairly different assertion and configuration involved.
|
|
I am okay with that, it's ncie to have testcase but if the test construtions cannot be the same across all tests then it defeat to use testcase... i am guessing all LLMs failed to do it properly? |
Yes, the current code is the best version that was generated. |
π Description of the Change
Add comprehensive unit test coverage for StartPR functionality in new pipelineascode_startpr_test.go file.
π¨π»β Linked Jira
https://issues.redhat.com/browse/SRVKP-9060
π Linked GitHub Issue
N/A
π 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 [email protected]
Co-authored-by: ChatGPT [email protected]
Co-authored-by: Claude [email protected]
Co-authored-by: Cursor [email protected]
Co-authored-by: Copilot [email protected]
**π‘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.