-
Notifications
You must be signed in to change notification settings - Fork 35
[WIP]: add more unit test #4017
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: master
Are you sure you want to change the base?
Conversation
|
Skipping CI for Draft Pull Request. |
|
[FORMAT CHECKER NOTIFICATION] Notice: To remove the 📖 For more info, you can check the "Contribute Code" section in the development guide. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @wk989898, 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 project's test suite by adding a substantial volume of new unit tests and improving existing ones. The changes aim to bolster the stability and correctness of critical components by covering more edge cases, validating configurations rigorously, and ensuring proper behavior under various conditions. The integration of Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 significant number of unit tests across various packages, which greatly enhances the project's test coverage and robustness. The new tests are well-structured and cover many important scenarios, including concurrency and edge cases. Additionally, the PR improves the testing infrastructure by setting up leak detection in several packages. I've found one test case that appears to be testing Go's standard library functions instead of project-specific code, which I've left a comment on. Overall, this is a valuable contribution to improving the project's quality.
| func TestDecodePassword(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| password string | ||
| want string | ||
| needEncode bool | ||
| needEscape bool | ||
| }{ | ||
| { | ||
| name: "case1", | ||
| password: "123456", | ||
| want: "123456", | ||
| }, | ||
| { | ||
| name: "case2", | ||
| password: "asdeer112", | ||
| want: "asdeer112", | ||
| needEncode: true, | ||
| }, | ||
| { | ||
| name: "case3", | ||
| password: "asdeer112!@#&", | ||
| want: "asdeer112!@#&", | ||
| needEscape: true, | ||
| }, | ||
| { | ||
| name: "case4", | ||
| password: "!@#12312//", | ||
| want: "!@#12312//", | ||
| needEncode: true, | ||
| needEscape: true, | ||
| }, | ||
| } | ||
| for _, c := range tests { | ||
| var err error | ||
| if c.needEscape { | ||
| c.password = url.QueryEscape(c.password) | ||
| } | ||
| if c.needEncode { | ||
| c.password = base64.StdEncoding.EncodeToString([]byte(c.password)) | ||
| tem, err := base64.StdEncoding.DecodeString(c.password) | ||
| c.password = string(tem) | ||
| require.NoError(t, err, c.name) | ||
| } | ||
| if c.needEscape { | ||
| c.password, err = url.QueryUnescape(c.password) | ||
| require.NoError(t, err, c.name) | ||
| } | ||
| require.Equal(t, c.want, c.password) | ||
| } | ||
| } |
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.
The test TestDecodePassword appears to test the behavior of Go's standard library functions (url.QueryEscape, url.QueryUnescape, base64.StdEncoding.EncodeToString, base64.StdEncoding.DecodeString) rather than any specific function from this package. It doesn't seem to call a decodePassword function from the project. As it stands, this test adds little value by testing standard library behavior and could be confusing. If it's intended to test a specific function, that function should be called within the test. Otherwise, it might be better to remove this test to avoid confusion.
What problem does this PR solve?
Issue Number: close #xxx
What is changed and how it works?
Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note