Fix empty and len testifylint violations across test files#32171
Open
mmorel-35 wants to merge 1 commit into
Open
Fix empty and len testifylint violations across test files#32171mmorel-35 wants to merge 1 commit into
mmorel-35 wants to merge 1 commit into
Conversation
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR aligns Go tests with testifylint recommendations by replacing manual len(...)/empty-string checks with more idiomatic Testify assertions, and updates lint configuration to enforce these rules.
Changes:
- Replace
Equal(..., len(x))andLen(..., 0)patterns withLen,Empty, andNotEmptyassertions across multiple test packages. - Enable
testifylint’semptyandlenchecks in.golangci.ymlby removing them from the disabled list.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/registry/registry_test.go | Uses suite.Len instead of Equal(1, len(tags)) for tag count assertions. |
| pkg/kube/client_test.go | Uses assert.Empty for zero-length created/deleted result sets in rollback test. |
| pkg/engine/files_test.go | Uses assert.Empty for empty string assertion. |
| pkg/chart/v2/lint/rules/crds_test.go | Uses assert.Empty for no lint messages. |
| pkg/chart/v2/chart_test.go | Uses assert.Len for CRD count. |
| pkg/action/upgrade_test.go | Uses assert.Empty for dependency list emptiness. |
| pkg/action/list_test.go | Uses assert.Empty for empty result lists. |
| pkg/action/install_test.go | Uses assert.NotEmpty for manifest non-emptiness, assert.Empty for empty output buffer. |
| pkg/action/get_metadata_test.go | Uses assert.Empty for empty alias/app version strings. |
| pkg/action/action_test.go | Uses assert.Len for reconstructed/maps size checks; uses assert.Empty for empty notes. |
| internal/plugin/loader_test.go | Uses assert.Empty for empty plugin list. |
| internal/chart/v3/lint/rules/crds_test.go | Uses assert.Empty for no lint messages. |
| internal/chart/v3/chart_test.go | Uses assert.Len for CRD count. |
| .golangci.yml | Enables testifylint empty and len rules by removing them from the disable list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Removes
emptyandlenfrom testifylint'sdisablelist and fixes all 21 violations across 13 test files.Rule changes:
len:assert.Equal(t, n, len(x))/is.Equal(n, len(x))→assert.Len(t, x, n)/is.Len(x, n)empty:assert.Len(t, x, 0),assert.Equal(t, "", x),is.Equal(0, len(x)),is.NotEqual(len(x), 0)→assert.Empty/assert.NotEmpty/is.Empty/is.NotEmptyFiles updated:
internal/chart/v3/chart_test.go,pkg/chart/v2/chart_test.go,internal/chart/v3/lint/rules/crds_test.go,pkg/chart/v2/lint/rules/crds_test.go,internal/plugin/loader_test.go,pkg/action/action_test.go,pkg/action/get_metadata_test.go,pkg/action/install_test.go,pkg/action/list_test.go,pkg/action/upgrade_test.go,pkg/engine/files_test.go,pkg/kube/client_test.go,pkg/registry/registry_test.go,.golangci.ymlSpecial notes for your reviewer:
All changes are mechanical assertion rewrites; semantics are identical.
If applicable:
docs neededlabel should be applied if so)