Review comments from PR review

Signed-off-by: Evans Mungai <mbuevans@gmail.com>
pull/31601/head
Evans Mungai 9 months ago
parent 10c4c253a2
commit 12bee37367
No known key found for this signature in database
GPG Key ID: BBEB812143DD14E1

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

Loading…
Cancel
Save