-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Enable testifylint to lint test files, and mechanically fix reported issues #35237
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ci-integration |
157d827
to
ce13d27
Compare
/ci-integration |
Note this needs a rebase. |
In preparation for the subsequent testifylint mechanical changes, let's convert an incorrect Error assertion into the corresponding ErrorContains one. Error asserts that the second argument is a non-nil error, which in this case was always true. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
In preparation for the subsequent testifylint mechanical changes, let's fix an incorrect NoError assertion, so that it actually checks the error returned by LinkSetUp, rather than the error already validated by the previous assertion. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
In preparation for the subsequent testifylint mechanical changes, let's anticipate these modifications. The mechanical ones would indeed lead to a failing test due to using Equal rather than EqualValues, which also asserts type equality (map values are of type uint64 here). Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
In preparation for the subsequent testifylint mechanical changes, let's anticipate these modifications. The mechanical ones would indeed lead to a failing test when asserting that the `selections` variable is nil, because the zero type of a slice is not equal to nil, but satisfies assert.Nil. Hence, let's just check that the slice is correctly empty. For reference, all assertions in the following test pass: func TestFoo(t *testing.T) { var foo []int assert.NotEqual(t, nil, foo) assert.Nil(t, foo) assert.Empty(t, foo) } Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Drop unnecessary assertions, as they were basically testing constants. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable error-nil ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable bool-compare ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable compares ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable contains ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable empty ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable error-is-as ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable expected-actual ./... Manually restored the comments in one of the TestParseGetLabelValues assertions, which got incorrectly deleted by the mechanical fix. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable formatter ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable len ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable negative-positive ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Generated by: testifylint --fix --disable-all --enable nil-compare ./... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Enable testifylint to lint the usages of github.com/stretchr/testify, in an effort to improve the readability of tests (and failure outputs) and reduce the chance of flakes. This also aims to remove the need for mechanical code review comments to encourage the usage of idiomatic testify primitives. The current configuration disables the "float-compare", "go-require" and "require-error" checkers, as extra effort is required to fix the issues reported by them (require-error appears to also lead to false positives when used inside EventuallyWithT blocks). Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
2ac8ec7
to
5e82466
Compare
Yeah, this PR turned out being a conflicts magnet (not that I expected anything different). Let's try again. |
/test |
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cilium-cli
This PR contains changes related with cilium-cli
kind/cleanup
This includes no functional changes.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
release-note/misc
This PR makes changes that have no direct user impact.
sig/policy
Impacts whether traffic is allowed or denied based on user-defined policies.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enable testifylint to lint the usages of github.com/stretchr/testify, in an effort to improve the readability of tests (and failure outputs) and reduce the chance of flakes. This also aims to remove the need for mechanical code review comments to encourage the usage of idiomatic testify primitives.
The current configuration disables the "float-compare", "go-require" and "require-error" checkers, as extra effort is required to fix the issues reported by them (require-error appears to also lead to false positives when used inside EventuallyWithT blocks).
Note to the reviewers, all except the first five commits, and the last one, have been mechanically generated with the following script: