diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index 05cf64e12..d21d2014b 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -22,6 +22,7 @@ import ( "path/filepath" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "helm.sh/helm/v4/internal/test/ensure" @@ -487,39 +488,32 @@ func TestDownloadToCache(t *testing.T) { } func TestStripDigestAlgorithm(t *testing.T) { - tests := []struct { - name string + tests := map[string]struct { input string expected string }{ - { - name: "sha256 prefixed digest", + "sha256 prefixed digest": { input: "sha256:aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d", expected: "aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d", }, - { - name: "sha512 prefixed digest", + "sha512 prefixed digest": { input: "sha512:abcdef1234567890", expected: "abcdef1234567890", }, - { - name: "plain hex digest without prefix", + "plain hex digest without prefix": { input: "aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d", expected: "aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d", }, - { - name: "empty string", + "empty string": { input: "", expected: "", }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for name, tt := range tests { + t.Run(name, func(t *testing.T) { result := stripDigestAlgorithm(tt.input) - if result != tt.expected { - t.Errorf("stripDigestAlgorithm(%q) = %q, want %q", tt.input, result, tt.expected) - } + assert.Equalf(t, tt.expected, result, "stripDigestAlgorithm(%q) = %q, want %q", tt.input, result, tt.expected) }) } }