Skip to content

Fix empty and len testifylint violations across test files#32171

Open
mmorel-35 wants to merge 1 commit into
helm:mainfrom
mmorel-35:empty-len
Open

Fix empty and len testifylint violations across test files#32171
mmorel-35 wants to merge 1 commit into
helm:mainfrom
mmorel-35:empty-len

Conversation

@mmorel-35
Copy link
Copy Markdown
Contributor

Removes empty and len from testifylint's disable list 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.NotEmpty

Files 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.yml

Special notes for your reviewer:

All changes are mechanical assertion rewrites; semantics are identical.

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Copilot AI review requested due to automatic review settings May 29, 2026 06:02
@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) and Len(..., 0) patterns with Len, Empty, and NotEmpty assertions across multiple test packages.
  • Enable testifylint’s empty and len checks in .golangci.yml by 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.

Copy link
Copy Markdown
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants